kane v0.1.1 Kane.Message
Kane.Message
provides an interface for publishing messaages to a topic.
A %Kane.Message{}
struct’s data
can be any type that can be serialized
to JSON via Poison.encode/1
. You can also add optional attributes to a
message, all of whose values must be strings (a restriction of the Pub/Sub API).
%Kane.Message{
data: "Any serializable type. This could be a map or list or whatever",
attributes: %{map: "of", key: "and", string: "values"}
}
Summary
Functions
Publish a message or a list of messages. When publishing a single message, the
message can be either a %Kane.Message{}
or the data you wish to use as the
message data. When publishing a list of messages, each item in the list must be
a %Kane.Message{}
Types
Functions
Specs
publish(binary, binary) ::
{:ok, t} |
Kane.Client.Response.Error.t
publish(t, Kane.Topic.t) ::
{:ok, t} |
Kane.Client.Response.Error.t
publish([t], Kane.Topic.t) ::
{:ok, [t]} |
Kane.Client.Response.Error.t
Publish a message or a list of messages. When publishing a single message, the
message can be either a %Kane.Message{}
or the data you wish to use as the
message data. When publishing a list of messages, each item in the list must be
a %Kane.Message{}
.
Kane will serialize the message to JSON and encode the message to base64 for you before publishing, as per the Pub/Sub spec.
%Kane.Message{data: "my message"} |> Kane.Message.publish(%Topic{name: "messages"})