funcatron.tron.util
ABase64Encoder
protocol
members
base64encode
(base64encode what)
as-int
(as-int s)
(as-int s default)
Take anything and try to convert it to an int
CalcSha256
protocol
Calculate the SHA for something
camel-stringify-keys
(camel-stringify-keys m)
(camel-stringify-keys f m)
Recursively transforms all map keys from keywords to camel strings.
clean-sha
(clean-sha s)
Take a base-64 encoded sha and turn it into a valid RabbitMQ name
compute-host-and-port
(compute-host-and-port opts)
Computes the hostname and port -- FIXME this should be pluggable for Mesos deploys and such
dev-mode?
(dev-mode? opts)
Calculates if we're in Dev mode from options
dns-lookup
(dns-lookup name)
Look up the SRV DNS records
encode-body
(encode-body data)
Base64 Encode the body's bytes. Pass data to `to-byte-array` and Base64 encode the result
ensure-json-clean
(ensure-json-clean v)
Return the value if it can be JSON serialized
file-from-classloader
(file-from-classloader cl name)
Given a classloader and a filename, return the String contents of the file, if available
first-matching-key
(first-matching-key m & potential)
Given a map, find the first matching key in the collection
fix-payload
multimethod
Converts a byte-array body into something full by content type
FuncMaker
protocol
Make a Java function out of stuff
members
to-java-function
(to-java-function v)
Convert the incoming thing to a Java Function
git-sha-from-classloader
(git-sha-from-classloader cl)
Try a bunch of strategies to get the git sha from the classloader
git-sha-txt
(git-sha-txt cl)
Given a classloader, try to slurp the gitsha.txt file and return its contents
graceful-exit
(graceful-exit code)
Gracefully exit the process. This means on Mesos, telling Mesos to terminate us
in-mesos?
(in-mesos?)
Returns true if we're running in mesos
jackson-deserializer
A Java BiFunction that takes an InputStream and target class and returns a Jackson read-type
jackson-json
The Jackson JSON ObjectMapper
jackson-serializer
A Java function that serializes any object to a byte array
json-clean
(json-clean m)
Recursively make sure the data nodes are JSON serializable
kebab-keywordize-keys
(kebab-keywordize-keys m)
(kebab-keywordize-keys f m)
Recursively transforms all map keys from strings to kebab keywords.
keywordize-keys
(keywordize-keys m)
(keywordize-keys f m)
Recursively transforms all map keys from strings to keywords.
kwd-to-string
(kwd-to-string kw?)
Converts a keyword to a nsless String
logger-for
(logger-for log-props)
Create a java.util.Logger instance that actually sends log events to Timbre.
Properties we care about :queue, :host, :basePath, :sha, :reply-to, :host-extra, :line-extra, :line-sep
make-ring-request
(make-ring-request req)
Takes normalized request and turns it into a Ring style request
manifest-from-classloader
(manifest-from-classloader cl)
Pass in a classloader and get the Manifest out
new-file
(new-file base name)
Create a new File object.
preserve-body
(preserve-body handler)
So, sometimes Ring middleware is destructive, which sucks... so
if there's a body field and it's a stream, slurp the bytes and allow
the stream to be restored
random-uuid
(random-uuid)
Create a Random UUID string via Java's UUID class
restore-body
(restore-body req)
Okay... if we've preserved the body, restore it
route-to-sha
(route-to-sha host path)
run-after
(run-after func delay)
Runs a function (IFn, Callable, Runnable) in the threadpool in `delay` milliseconds
run-in-pool
(run-in-pool func)
Runs a function (IFn, Callable, Runnable) in the threadpool
runner-mode?
(runner-mode? opts)
Calculates if we're in Dev mode from options
some-when
(some-when element function)
Return the element if the element passed to the function returns true
square-numbers
(square-numbers m)
Takes a map. For each key that has a value that's a number, create key-sq with the squared number.
For non-number values, drop them
start-http-server
(start-http-server opts function)
Starts a http-kit server with the options specified in command line options. `function` is the Ring handler.
Returns the Stop Server function
string-to-kwd
(string-to-kwd s?)
Converts a String to a Keyword
string-to-properties
(string-to-properties s)
Read a String as Java properties format and then kebab-keywordize it
stringify-keys
(stringify-keys m)
(stringify-keys f m)
Recursively transforms all map keys from keywords to strings.
time-execution
(time-execution f)
Takes a function. Runs the function and returns the functions return value along with timing information.
ToByteArray
protocol
Convert the incoming value to a byte array
members
to-byte-array
(to-byte-array v)
Convert v to a byte array and return the content type and byte array
ToClojureFunc
protocol
Converts a Function into a Clojure Function
members
to-clj-func
(to-clj-func f)
ToJavaFunction
protocol
Converts a wide variety of stuff into a Java function
transit-decode
(transit-decode bytes)
Takes a byte array and returns the transit decoded object
transit-encode
(transit-encode obj)
Takes an object and transit-encodes the object. Returns a byte array
tron-mode?
(tron-mode? opts)
Calculates if we're in Tron mode from options
TupleUtil
protocol
members
from-tuple
(from-tuple this)
version-info-from-classloader
(version-info-from-classloader cl)
Pass in a classloader and get various version information into a map
walk
(walk element-f key-f data)
Walk Clojure data structures and 'do the right thing'
within-classloader
(within-classloader cl the-fn)
Set the context classloader for execution of the function
xml-to-utf-byte-array
(xml-to-utf-byte-array node)
Take XML and convert it into UTF-8 encoded byte array