Liking cljdoc? Tell your friends :D

blizzard.core

HTTP Flake ID generation service.

Blizzard provides a Ring middleware which adds two routes, /flake and /flake/:n which generate a single flake and N flakes, respectively. Responses are of content type application/transit+json and as such a transit client should be used to read them.

While Blizzard may to used as a standalone service, because it is implemented as as a middleware it can be attached to any application where the routes do not conflict. For example:

=> (def handler (-> (constantly {:status 404 :body "Not Found"}) wrap-flake))

Of course, other middleware may be added as desired. Note that above handler should be passed to an adapter such as ring-jetty.

For standalone use, the following environment variables provide runtime configuration:

BLIZZARD_HOST - Defaults to localhost. BLIZZARD_PORT - Defaults to 3000. BLIZZARD_MAX_IDS - The maximum allowed IDs per batch request. Default 1000. BLIZZARD_JETTY_OPTS - Defaults to {:join? true}.

HTTP Flake ID generation service.

Blizzard provides a Ring middleware which adds two routes, /flake and
/flake/:n which generate a single flake and N flakes, respectively. Responses
are of content type application/transit+json and as such a transit client
should be used to read them.

While Blizzard may to used as a standalone service, because it is implemented
as as a middleware it can be attached to any application where the routes do
not conflict. For example:

  => (def handler (-> (constantly {:status 404 :body "Not Found"})
                      wrap-flake))

Of course, other middleware may be added as desired. Note that above handler
should be passed to an adapter such as ring-jetty.

For standalone use, the following environment variables provide runtime
configuration:

BLIZZARD_HOST       - Defaults to localhost.
BLIZZARD_PORT       - Defaults to 3000.
BLIZZARD_MAX_IDS    - The maximum allowed IDs per batch request. Default
                      1000.
BLIZZARD_JETTY_OPTS - Defaults to {:join? true}.
raw docstring

-mainclj

(-main & _)
source

accept->fmtclj

(accept->fmt accept)

Returns a transit format (either :json or :msgpack, defaulting to :json) based on the value of the Accept header.

Returns a transit format (either :json or :msgpack, defaulting to :json)
based on the value of the Accept header.
sourceraw docstring

get-envclj

(get-env k & [default])

Gets an environment variable k. An optional default is used when values are missing.

Gets an environment variable k. An optional default is used when values are
missing.
sourceraw docstring

ids-responseclj

(ids-response method max-ids fmt & [{:keys [n] :or {n "1"}}])

Returns a response with an appropriate number of ids.

Returns a response with an appropriate number of ids.
sourceraw docstring

method-not-allowedclj

source

n-or-1clj

(n-or-1 n)

Returns n if n is greater than 0 otherwise 1.

Returns n if n is greater than 0 otherwise 1.
sourceraw docstring

n-or-max-idsclj

(n-or-max-ids n max-ids)

Returns n if n is equal to or less than max-ids.

Returns n if n is equal to or less than max-ids.
sourceraw docstring

string->integerclj

(string->integer s)

Converts s to an integer.

Converts s to an integer.
sourceraw docstring

take-idsclj

(take-ids n)

Repeatedly calls flake/generate n times, returns the result.

Repeatedly calls flake/generate n times, returns the result.
sourceraw docstring

transit-writeclj

(transit-write data fmt)

Writes data with the given fmt (either :json or :msgpack) into a ByteArrayOutputStream as transit data. Returns the output stream.

Writes data with the given fmt (either :json or :msgpack) into a
ByteArrayOutputStream as transit data. Returns the output stream.
sourceraw docstring

wrap-flakeclj

(wrap-flake handler & [{:keys [max-ids]}])

Middleware that adds two routes to a Ring application:

/flake - Returns a single Flake ID. /flake/:n - Returns N Flake IDs.

Takes an optional map containing a key max-id, the maximum allowed number of keys. Defaults to 1000.

Middleware that adds two routes to a Ring application:

  /flake    - Returns a single Flake ID.
  /flake/:n - Returns N Flake IDs.

Takes an optional map containing a key max-id, the maximum allowed number
of keys. Defaults to 1000.
sourceraw docstring

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

× close