Liking cljdoc? Tell your friends :D

hive.events.cloudevents

CloudEvents 1.0 context attributes and the NATS binary content mode codec. Pure, cljc.

Attributes are a map with unqualified keyword keys named after the CloudEvents attribute (:specversion :id :source :type :time ...). Every value is its canonical CloudEvents string, except the one hive extension :hiveschemaversion, a positive Integer.

In binary content mode every attribute travels as its own NATS header named ce-<attribute>, the value percent-encoded as section 3.1.3.2 of the CloudEvents NATS protocol binding prescribes. The event data is the message body and is never read or written here.

Spec: https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md Binding: https://github.com/cloudevents/spec/blob/main/cloudevents/bindings/nats-protocol-binding.md

Every fn that can refuse returns a hive-dsl Result: {:ok v} or {:error kw ...}.

CloudEvents 1.0 context attributes and the NATS binary content mode codec.
Pure, cljc.

Attributes are a map with unqualified keyword keys named after the
CloudEvents attribute (:specversion :id :source :type :time ...). Every value
is its canonical CloudEvents string, except the one hive extension
:hiveschemaversion, a positive Integer.

In binary content mode every attribute travels as its own NATS header named
`ce-<attribute>`, the value percent-encoded as section 3.1.3.2 of the
CloudEvents NATS protocol binding prescribes. The event data is the message
body and is never read or written here.

Spec: https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md
Binding: https://github.com/cloudevents/spec/blob/main/cloudevents/bindings/nats-protocol-binding.md

Every fn that can refuse returns a hive-dsl Result: {:ok v} or {:error kw ...}.
raw docstring

->headersclj/s

(->headers attrs)
(->headers attrs {:keys [content-type?]})

Result of mapping valid attrs to NATS binary content mode headers: one header ce-<name> per attribute, lower-case names, percent-encoded values. datacontenttype travels as ce-datacontenttype, as section 3.1.3.1 of the binding requires. With opts {:content-type? true} it is also mirrored to the content-type header for consumers that are not CloudEvents aware.

Result of mapping valid `attrs` to NATS binary content mode headers: one
header `ce-<name>` per attribute, lower-case names, percent-encoded values.
datacontenttype travels as ce-datacontenttype, as section 3.1.3.1 of the
binding requires. With opts {:content-type? true} it is also mirrored to
the `content-type` header for consumers that are not CloudEvents aware.
sourceraw docstring

<-headersclj/s

(<-headers m)

Result of reading the CloudEvents attributes out of NATS headers m (header name to value, or to a sequence of values, first one wins). Header names are matched case-insensitively. Headers without the ce- prefix are ignored, except content-type, which supplies datacontenttype when no ce-datacontenttype header is present. A ce- header whose suffix is not a legal attribute name is refused. The attributes are validated.

Result of reading the CloudEvents attributes out of NATS headers `m`
(header name to value, or to a sequence of values, first one wins). Header
names are matched case-insensitively. Headers without the ce- prefix are
ignored, except `content-type`, which supplies datacontenttype when no
ce-datacontenttype header is present. A ce- header whose suffix is not a
legal attribute name is refused. The attributes are validated.
sourceraw docstring

attribute-name?clj/s

(attribute-name? s)

True when s is a legal CloudEvents attribute name: lower-case ASCII letters and digits, length 1 to 20 (spec: Attribute Naming Convention).

True when `s` is a legal CloudEvents attribute name: lower-case ASCII letters
and digits, length 1 to 20 (spec: Attribute Naming Convention).
sourceraw docstring

AttributeNameclj/s

source

Attributesclj/s

CloudEvents 1.0 context attributes, open for extensions. The required four, the optional ones hive uses, and the hiveschemaversion extension. Any other key is an extension: its name must be a legal attribute name and its value a CloudEvents String.

CloudEvents 1.0 context attributes, open for extensions. The required four,
the optional ones hive uses, and the hiveschemaversion extension. Any other
key is an extension: its name must be a legal attribute name and its value a
CloudEvents String.
sourceraw docstring

CEStringclj/s

source

decode-header-valueclj/s

(decode-header-value s)

Result of turning a received header value into the attribute's canonical string: unquote, then one round of percent-decoding.

Result of turning a received header value into the attribute's canonical
string: unquote, then one round of percent-decoding.
sourceraw docstring

envelopeclj/s

(envelope {:keys [id clock time type source subject datacontenttype dataschema
                  hiveschemaversion extensions]})

Result of building validated attributes for one event. Nothing is read from the environment: the id and the clock are passed in.

m takes :type and :source (required); :id, a string or a 0-arity fn returning one (required); :clock, a 0-arity fn returning epoch millis, or :time, an RFC 3339 string; optional :subject, :datacontenttype, :dataschema, :hiveschemaversion (default schema-version) and :extensions, a map of further attribute keyword to string.

Result of building validated attributes for one event. Nothing is read from
the environment: the id and the clock are passed in.

`m` takes :type and :source (required); :id, a string or a 0-arity fn
returning one (required); :clock, a 0-arity fn returning epoch millis, or
:time, an RFC 3339 string; optional :subject, :datacontenttype, :dataschema,
:hiveschemaversion (default `schema-version`) and :extensions, a map of
further attribute keyword to string.
sourceraw docstring

epoch-millis->rfc3339clj/s

(epoch-millis->rfc3339 ms)

RFC 3339 UTC timestamp of ms milliseconds since the epoch, with millisecond precision: 2018-04-05T03:56:24.000Z. Identical on clj and cljs.

RFC 3339 UTC timestamp of `ms` milliseconds since the epoch, with
millisecond precision: 2018-04-05T03:56:24.000Z. Identical on clj and cljs.
sourceraw docstring

header-prefixclj/s

source

Int32Posclj/s

source

NonEmptyCEStringclj/s

source

percent-decodeclj/s

(percent-decode s)

Result of one round of percent-decoding the header value s. Lower-case hex and needlessly encoded characters are accepted; invalid UTF-8 is refused.

Result of one round of percent-decoding the header value `s`. Lower-case hex
and needlessly encoded characters are accepted; invalid UTF-8 is refused.
sourceraw docstring

percent-encodeclj/s

(percent-encode s)

Header value for the canonical string s, percent-encoded with upper-case hex as the binding requires.

Header value for the canonical string `s`, percent-encoded with upper-case
hex as the binding requires.
sourceraw docstring

rfc3339?clj/s

(rfc3339? s)

True when s is an RFC 3339 date-time (section 5.6), with field ranges checked.

True when `s` is an RFC 3339 date-time (section 5.6), with field ranges
checked.
sourceraw docstring

schema-versionclj/s

The value of the hiveschemaversion extension stamped by envelope.

The value of the hiveschemaversion extension stamped by `envelope`.
sourceraw docstring

spec-versionclj/s

The only CloudEvents specversion this codec speaks.

The only CloudEvents specversion this codec speaks.
sourceraw docstring

Timestampclj/s

source

validateclj/s

(validate attrs)

Result of checking attrs against Attributes. A key that is not a legal attribute name is refused as :cloudevents/invalid-attribute-name.

Result of checking `attrs` against `Attributes`. A key that is not a legal
attribute name is refused as :cloudevents/invalid-attribute-name.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close