Liking cljdoc? Tell your friends :D
Clojure only.

com.stitchdata.client.core

Clojure Stitch Client

Usage:

(ns foo.bar (:require [com.stitchdata.client.core :as sc]))

;; Build a client in a with-open. The client accumulates records in ;; batches, and we should close it when we're done to avoid leaving ;; messages in an unsent batch. (with-open [stitch (sc/client {::sc/client-id 1234 ::sc/token "adfadfadfadfadfaadfadfadfagdfa" ::sc/namespace "event_tracking"})] (doseq [data some-source-of-data] ;; Send a record to Stitch (sc/push stitch {::sc/action ::sc/upsert ::sc/table-name "events" ::sc/key-names ["hostname" "timestamp"] ::sc/sequence (System/currentTimeMillis) ::sc/data data})))

Clojure Stitch Client

Usage:

(ns foo.bar
  (:require [com.stitchdata.client.core :as sc]))

;; Build a client in a with-open. The client accumulates records in
;; batches, and we should close it when we're done to avoid leaving
;; messages in an unsent batch.
(with-open [stitch (sc/client {::sc/client-id 1234
                               ::sc/token "adfadfadfadfadfaadfadfadfagdfa"
                               ::sc/namespace "event_tracking"})]
  (doseq [data some-source-of-data]
    ;; Send a record to Stitch
    (sc/push stitch {::sc/action ::sc/upsert
                     ::sc/table-name "events"
                     ::sc/key-names ["hostname" "timestamp"]
                     ::sc/sequence (System/currentTimeMillis)
                     ::sc/data data})))
raw docstring

clientclj

(client client-spec)

Build a Stitch client.

Takes a map with the following structure and returns an instance of StitchClient:

{ ;; [Required] Credentials for Stitch ::sc/client-id 1234 ::sc/token "adfadfadfadfadfadfadfadfadfadfadfadfadfadfadfadf" ::sc/namespace "event_tracking"

;; [Optional] Default message values ::sc/table-name "events" ::sc/key-names ["hostname" "timestamp"]

;; [Optional] Batch tuning ::sc/batch-size-bytes 1000000 ;; Trigger batch at 1 Mb ::sc/batch-delay-millis 10000 ;; Trigger batch at 10 seconds }

Credentials

You should have received these when you set up the integration at http://stitchdata.com.

Default Message Values

If all the records you send with this client will be going to the same table, you can set a default table name and list of key names when you create the client with the ::sc/table-name and ::sc/key-names keys. You can then omit those values from the messages.

Batch Tuning

The client will accumulate messages in batches, and send the batch when one of the following conditions is met:

  • Accumulated 4 Mb of data
  • Accumulated 10,000 records
  • 1 minute has passed since we sent the last batch

You can tune the amount of data to require before triggering a batch with ::sc/batch-size-bytes. Values higher than 4 Mb will be ignored, because 4 Mb is the maximum message size Stitch will accept. You can tune the amount of time to let pass before triggering a batch with ::sc/batch-delay-millis.

Thread Safety

Instances of StitchClient are not thread safe. Concurrent calls to push will result in lost or corrupt data.

Build a Stitch client.

Takes a map with the following structure and returns an instance of
StitchClient:

{
 ;; [Required] Credentials for Stitch
 ::sc/client-id 1234
 ::sc/token     "adfadfadfadfadfadfadfadfadfadfadfadfadfadfadfadf"
 ::sc/namespace "event_tracking"

 ;; [Optional] Default message values
 ::sc/table-name    "events"
 ::sc/key-names     ["hostname" "timestamp"]

 ;; [Optional] Batch tuning
 ::sc/batch-size-bytes   1000000 ;; Trigger batch at 1 Mb
 ::sc/batch-delay-millis   10000 ;; Trigger batch at 10 seconds
}

Credentials
-----------

You should have received these when you set up the integration at
http://stitchdata.com.

Default Message Values
----------------------

If all the records you send with this client will be going to the
same table, you can set a default table name and list of key names
when you create the client with the ::sc/table-name
and ::sc/key-names keys. You can then omit those values from the
messages.

Batch Tuning
------------

The client will accumulate messages in batches, and send the batch
when one of the following conditions is met:

  * Accumulated 4 Mb of data
  * Accumulated 10,000 records
  * 1 minute has passed since we sent the last batch

You can tune the amount of data to require before triggering a batch
with ::sc/batch-size-bytes. Values higher than 4 Mb will be ignored,
because 4 Mb is the maximum message size Stitch will accept. You can
tune the amount of time to let pass before triggering a batch
with ::sc/batch-delay-millis.

Thread Safety
-------------

Instances of StitchClient *are not* thread safe. Concurrent calls to
`push` will result in lost or corrupt data.
sourceraw docstring

pushclj

(push client message)

Adds the given message to the current batch, sending it if it is ready.

client must be an instance of StitchClient, obtained with the client function.

message must be a map with the following structure:

{::sc/action ::sc/upsert ::sc/table-name "my_table" ::sc/key-names ["hostname" "timestamp"] ::sc/sequence 123456789 ::sc/data {"id" 1, "name" "John"}}

Adds the given message to the current batch, sending it if it is ready.

client must be an instance of StitchClient, obtained with the `client` function.

message must be a map with the following structure:

{::sc/action ::sc/upsert
 ::sc/table-name "my_table"
 ::sc/key-names ["hostname" "timestamp"]
 ::sc/sequence 123456789
 ::sc/data {"id" 1, "name" "John"}}
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close