PubSubMessage

is the decoded form of a reply pushed to a subscribed connection. After subscribe or psubscribe, read the stream of pushed replies with next-message, which turns each raw RESP value into one of these variants using decode-message.

(match (Redis.subscribe &r @"news")
  (Result.Success _)
    (match (Redis.next-message &r)
      (Result.Success msg)
        (match msg
          (PubSubMessage.Message channel payload)
            (println* "got " &payload " on " &channel)
          (PubSubMessage.Subscribe channel count)
            (println* "subscribed to " &channel)
          _ (println* "other pub/sub reply"))
      (Result.Error e) (IO.errorln &e))
  (Result.Error e) (IO.errorln &e))

Message

instantiate

(Fn [String, String] PubSubMessage)

creates a Message.

PMessage

instantiate

(Fn [String, String, String] PubSubMessage)

creates a PMessage.

PSubscribe

instantiate

(Fn [String, Int] PubSubMessage)

creates a PSubscribe.

PUnsubscribe

instantiate

(Fn [String, Int] PubSubMessage)

creates a PUnsubscribe.

Subscribe

instantiate

(Fn [String, Int] PubSubMessage)

creates a Subscribe.

Unsubscribe

instantiate

(Fn [String, Int] PubSubMessage)

creates a Unsubscribe.

copy

instantiate

(Fn [(Ref PubSubMessage a)] PubSubMessage)

copies a PubSubMessage.

decode-message

defn

(Fn [(Ref RESP a)] (Result PubSubMessage String))

                        (decode-message r)
                    

decodes a pushed pub/sub reply r into a PubSubMessage.

The reply is expected to be a RESP.Arr whose first element is a bulk string naming the kind (message, pmessage, subscribe, unsubscribe, psubscribe or punsubscribe). Returns an Error for any other RESP shape, an unknown kind, a wrong element count, or a field of the wrong type.

delete

instantiate

(Fn [PubSubMessage] ())

deletes a PubSubMessage. This should usually not be called manually.

get-tag

instantiate

(Fn [(Ref PubSubMessage a)] Int)

Gets the tag from a PubSubMessage.

prn

instantiate

(Fn [(Ref PubSubMessage a)] String)

converts a PubSubMessage to a string.

str

instantiate

(Fn [(Ref PubSubMessage a)] String)

converts a PubSubMessage to a string.