Help us shape the future of Go! Take the 2026 Go Developer Survey

protocol

package module
v0.23.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 16 Imported by: 10

README

protocol

Centrifugal client-server protocol definitions and codecs for Go.

build GoDoc Release License Telegram Discord

This package contains the client-server protocol used by Centrifugo and the Centrifuge library, together with the encoders and decoders they use on hot paths.

The protocol is defined once in client.proto and can be serialized either as JSON or as Protobuf – the two representations are generated from the same definitions, so they never drift apart. Client SDKs in other languages generate their own code from the very same file.

Install

go get github.com/centrifugal/protocol

Most applications never import this package directly – they use Centrifugo or Centrifuge, which depend on it. Import it directly when implementing a client, a transport, or tooling that speaks the Centrifugal protocol.

Protocol in a nutshell

There are three top-level messages:

Message Direction Purpose
Command client -> server Carries exactly one request, e.g. ConnectRequest, SubscribeRequest, PublishRequest.
Reply server -> client Answers a Command with a result or an Error, or wraps an asynchronous Push.
Push server -> client Asynchronous message, e.g. Publication, Join, Leave, Disconnect.

Several messages may be streamed inside a single transport frame. In JSON they are separated by a \n delimiter, in Protobuf each message is prefixed with its length encoded as a varint.

Application payloads (such as Publication.Data) use the Raw type – a []byte passed through encoding as is, so a subscriber decodes the payload its publisher sent. The one exception is required by the JSON framing above and is documented on Raw.MarshalJSON.

Usage

Codecs are selected by protocol type and are usually taken from pools to keep the allocation count low:

decoder := protocol.GetCommandDecoder(protocol.TypeJSON, data)
defer protocol.PutCommandDecoder(protocol.TypeJSON, decoder)

for {
    cmd, err := decoder.Decode()
    if cmd != nil {
        // Handle the command.
    }
    if err != nil {
        if errors.Is(err, io.EOF) {
            break
        }
        return err
    }
}

See the package documentation for the full set of encoders and decoders, and client.proto for the message definitions with comments.

For a description of the protocol from the client point of view see the client protocol documentation on centrifugal.dev.

Generated code

client.pb.go, client.pb_cfprotobuf.go and client.pb_cfjson.go are generated and committed to the repo. After changing client.proto, regenerate them with:

make generate

The required tools and their pinned versions are listed at the top of generate.sh. The structs come from protoc-gen-go; the JSON and the Protobuf encoding and decoding code is produced by generators which live in this repo, see cfjson and cfprotobuf.

Development

make test   # run tests with race detector
make bench  # run benchmarks
make fuzz   # run fuzz targets for a short time
make lint   # run golangci-lint (CI pins its version in .golangci-lint-version)

Decoders are fuzzed nightly in CI, see .github/workflows/fuzz.yml.

Security

To report a vulnerability, see SECURITY.md.

License

MIT, see LICENSE.

Documentation

Overview

Package protocol contains client-server protocol definitions of the Centrifugal ecosystem (Centrifugo server and Centrifuge library) together with fast encoders and decoders for them.

The protocol is described in client.proto and consists of three top-level messages:

Serialization formats

Every message may be serialized either as JSON or as Protobuf, see Type. Both formats are generated from the same client.proto, so the two are always in sync. Which one is used is negotiated by the transport – JSON is the default, Protobuf is used by clients which need a more compact binary representation.

Messages of both formats can be streamed one after another inside a single transport frame. In JSON messages are separated by a `\n` delimiter, in Protobuf every message is prefixed with its length encoded as a varint.

Encoders and decoders

The package does not expose a single generic Marshal/Unmarshal pair. Instead it provides narrow interfaces for the parts of the protocol a server or a client needs to touch, each with a JSON and a Protobuf implementation:

Implementations are chosen by protocol Type, usually through the pooled helpers – GetCommandDecoder/PutCommandDecoder, GetDataEncoder/PutDataEncoder, GetStreamCommandDecoderLimited/PutStreamCommandDecoder and ReplyPool. These helpers reuse objects between messages and let a server avoid allocations on hot paths.

Payloads

Application-specific payloads (such as Publication Data) use the Raw type. Raw is a []byte which is passed through encoding as is, so the payload a publisher sent is the payload a subscriber decodes – see Raw.MarshalJSON for the single exception required by the JSON framing.

Stability

The protocol itself is backwards compatible: fields are only added, never repurposed. The Go API of this package is shaped by the needs of Centrifugo and Centrifuge, and while it rarely changes it does not provide the compatibility guarantees of a v1 module – pin a version when depending on it directly.

Index

Examples

Constants

View Source
const (
	// FrameCodecRaw marks a frame whose payload follows verbatim. Every receiver
	// must support it: a sender falls back to it whenever compression would not
	// shrink a frame, or has been measured not to pay off for a connection.
	FrameCodecRaw byte = 0x00
	// FrameCodecCompressed marks a frame compressed with whatever codec this
	// connection negotiated, against its active dictionary.
	FrameCodecCompressed byte = 0x01
)

Once a connection has negotiated frame compression, every frame starts with one of these markers.

The marker deliberately does not name a codec. Which codec a connection uses is settled once, at connect, by the capability flags the client advertised, so repeating it per frame would be redundant - and would make every new codec a protocol change. The marker only answers the one question that genuinely varies frame to frame: was this frame compressed at all.

View Source
const MinDictionaryCompressionLevel = 2

MinDictionaryCompressionLevel is the lowest level NewDeflateFrameCodec accepts.

DEFLATE implementations switch to specialised fast encoders below this which ignore the preset dictionary completely while still accepting it. The standard library does this at level 1: measured on a 61 byte frame against a 4KB dictionary it emits 66 bytes, versus 24 bytes at level 2 and above and 60 bytes with no dictionary at all. A level below this does not trade ratio for speed, it silently disables the entire feature while still paying to carry the dictionary around - so NewDeflateFrameCodec panics rather than accept one.

TestFrameCodecDictionaryActuallyApplies guards this.

Variables

View Source
var (
	// ErrFrameTooLarge is returned when a compressed frame expands beyond the
	// caller supplied limit. Without it a small frame could be inflated into an
	// arbitrary amount of memory.
	ErrFrameTooLarge = errors.New("centrifugal: decompressed frame too large")
	// ErrUnknownFrameCodec is returned for a frame marker the codec does not know.
	ErrUnknownFrameCodec = errors.New("centrifugal: unknown frame codec")
	// ErrEmptyFrame is returned for a frame with no codec marker at all.
	ErrEmptyFrame = errors.New("centrifugal: empty frame")
)
View Source
var (
	DefaultJsonPushEncoder     = NewJSONPushEncoder()
	DefaultProtobufPushEncoder = NewProtobufPushEncoder()
)

Default push encoders returned by GetPushEncoder. They are stateless, so a single instance per protocol type is shared by all connections.

View Source
var (
	DefaultJsonReplyEncoder     = NewJSONReplyEncoder()
	DefaultProtobufReplyEncoder = NewProtobufReplyEncoder()
)

Default reply encoders returned by GetReplyEncoder. They are stateless, so a single instance per protocol type is shared by all connections.

View Source
var ErrMessageTooLarge = errors.New("message size exceeds the limit")

ErrMessageTooLarge is returned by a StreamCommandDecoder when a command in the stream exceeds the configured message size limit.

View Source
var File_client_proto protoreflect.FileDescriptor
View Source
var ReplyPool = &ReplyPoolCollection{}

ReplyPool is the shared collection of Reply pools.

Every Acquire method returns a Reply with the corresponding result field set, and with Id and Error zeroed. Once the Reply is encoded and no longer needed, pass it to the matching Release method – after that neither the Reply nor the result it referenced must be used.

Release clears the whole envelope, not just the result field: a pooled Reply is handed to a different connection next, so any Id or Error left on it would be sent to that connection instead.

Functions

func DeflateDictionary added in v0.21.0

func DeflateDictionary(dict []byte, level int) []byte

DeflateDictionary compresses dictionary content with raw DEFLATE and no preset dictionary, for delivery to a client that has nothing installed yet.

It carries no codec marker: this is content inside a Dictionary message rather than a frame, and dictionary content is always deflated, so there is nothing to signal. A dictionary is a concatenation of real message samples, so it is ordinary text and compresses several fold - which is the difference between a first dictionary a connection can afford and one it cannot.

level is a plain flate.NewWriter level: unlike NewDeflateFrameCodec's level, there is no preset dictionary here for a low level to silently ignore, so any valid flate level is fine - MinDictionaryCompressionLevel does not apply.

func InflateDictionary added in v0.21.0

func InflateDictionary(data []byte, maxSize int) ([]byte, error)

InflateDictionary reverses DeflateDictionary, refusing anything that would expand past maxSize so a small crafted payload cannot be inflated into an unbounded allocation.

func PutCommandDecoder

func PutCommandDecoder(protoType Type, e CommandDecoder)

PutCommandDecoder returns a CommandDecoder obtained with GetCommandDecoder to the pool. The decoder must not be used after that.

func PutDataEncoder added in v0.4.0

func PutDataEncoder(protoType Type, e DataEncoder)

PutDataEncoder returns a DataEncoder obtained with GetDataEncoder to the pool. The encoder must not be used after that, and neither must the slice returned by its FinishNoCopy method.

func PutResultEncoder

func PutResultEncoder(_ Type, _ ReplyEncoder)

PutResultEncoder is a no-op kept for symmetry with GetResultEncoder: result encoders are stateless, so there is nothing to return to a pool.

func PutStreamCommandDecoder added in v0.9.0

func PutStreamCommandDecoder(protoType Type, e StreamCommandDecoder)

PutStreamCommandDecoder returns a StreamCommandDecoder obtained with GetStreamCommandDecoderLimited to the pool. The decoder must not be used after that.

Types

type ByteBuffer added in v0.7.2

type ByteBuffer struct {
	// B is the underlying byte slice.
	B []byte
}

ByteBuffer implements a simple byte buffer.

func (*ByteBuffer) Reset added in v0.7.2

func (bb *ByteBuffer) Reset()

Reset resets bb.

func (*ByteBuffer) Write added in v0.7.2

func (bb *ByteBuffer) Write(p []byte) (int, error)

Write appends p to bb.

type ClientInfo

type ClientInfo struct {

	// User id. Empty for anonymous connections.
	User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user"`
	// Unique client (connection) id.
	Client string `protobuf:"bytes,2,opt,name=client,proto3" json:"client"`
	// Optional connection info attached by the application at connect time,
	// may be updated on connection refresh.
	ConnInfo Raw `protobuf:"bytes,3,opt,name=conn_info,json=connInfo,proto3" json:"conn_info,omitempty"`
	// Optional channel info attached by the application at subscribe time.
	ChanInfo Raw `protobuf:"bytes,4,opt,name=chan_info,json=chanInfo,proto3" json:"chan_info,omitempty"`
	// contains filtered or unexported fields
}

ClientInfo contains information about a client connection.

func (*ClientInfo) AppendJSON added in v0.23.0

func (m *ClientInfo) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*ClientInfo) DecodeJSON added in v0.23.0

func (m *ClientInfo) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*ClientInfo) Descriptor deprecated

func (*ClientInfo) Descriptor() ([]byte, []int)

Deprecated: Use ClientInfo.ProtoReflect.Descriptor instead.

func (*ClientInfo) GetChanInfo added in v0.7.0

func (x *ClientInfo) GetChanInfo() []byte

func (*ClientInfo) GetClient

func (x *ClientInfo) GetClient() string

func (*ClientInfo) GetConnInfo added in v0.7.0

func (x *ClientInfo) GetConnInfo() []byte

func (*ClientInfo) GetUser

func (x *ClientInfo) GetUser() string

func (*ClientInfo) MarshalCF added in v0.23.0

func (m *ClientInfo) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*ClientInfo) MarshalToCF added in v0.23.0

func (m *ClientInfo) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*ClientInfo) MarshalToSizedBufferCF added in v0.23.0

func (m *ClientInfo) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*ClientInfo) ProtoMessage

func (*ClientInfo) ProtoMessage()

func (*ClientInfo) ProtoReflect added in v0.7.0

func (x *ClientInfo) ProtoReflect() protoreflect.Message

func (*ClientInfo) Reset

func (x *ClientInfo) Reset()

func (*ClientInfo) SizeCF added in v0.23.0

func (m *ClientInfo) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*ClientInfo) String

func (x *ClientInfo) String() string

func (*ClientInfo) UnmarshalCF added in v0.23.0

func (m *ClientInfo) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type Command

type Command struct {

	// Id of the command, echoed back in Reply.id to let the client match replies
	// to commands. Must be > 0 for every command expecting a reply. Only a send
	// command, which never gets a reply, may have zero id.
	//
	// A command with zero id and no request set (empty Command) is a pong - the
	// response to a server ping, see ConnectResult.pong. A pong without a
	// preceding server ping results in a bad request disconnect.
	Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// Connect must be the first command sent over a connection. Any other
	// command before a successful connect results in a disconnect.
	Connect       *ConnectRequest       `protobuf:"bytes,4,opt,name=connect,proto3" json:"connect,omitempty"`
	Subscribe     *SubscribeRequest     `protobuf:"bytes,5,opt,name=subscribe,proto3" json:"subscribe,omitempty"`
	Unsubscribe   *UnsubscribeRequest   `protobuf:"bytes,6,opt,name=unsubscribe,proto3" json:"unsubscribe,omitempty"`
	Publish       *PublishRequest       `protobuf:"bytes,7,opt,name=publish,proto3" json:"publish,omitempty"`
	Presence      *PresenceRequest      `protobuf:"bytes,8,opt,name=presence,proto3" json:"presence,omitempty"`
	PresenceStats *PresenceStatsRequest `protobuf:"bytes,9,opt,name=presence_stats,json=presenceStats,proto3" json:"presence_stats,omitempty"`
	History       *HistoryRequest       `protobuf:"bytes,10,opt,name=history,proto3" json:"history,omitempty"`
	// Not supported by the server at the moment, see PingRequest.
	Ping *PingRequest `protobuf:"bytes,11,opt,name=ping,proto3" json:"ping,omitempty"`
	// Asynchronous message to the server, no Reply is sent in response.
	Send       *SendRequest       `protobuf:"bytes,12,opt,name=send,proto3" json:"send,omitempty"`
	Rpc        *RPCRequest        `protobuf:"bytes,13,opt,name=rpc,proto3" json:"rpc,omitempty"`
	Refresh    *RefreshRequest    `protobuf:"bytes,14,opt,name=refresh,proto3" json:"refresh,omitempty"`
	SubRefresh *SubRefreshRequest `protobuf:"bytes,15,opt,name=sub_refresh,json=subRefresh,proto3" json:"sub_refresh,omitempty"`
	// contains filtered or unexported fields
}

Command is sent from a client to a server.

func (*Command) AppendJSON added in v0.23.0

func (m *Command) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Command) DecodeJSON added in v0.23.0

func (m *Command) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Command) Descriptor deprecated

func (*Command) Descriptor() ([]byte, []int)

Deprecated: Use Command.ProtoReflect.Descriptor instead.

func (*Command) GetConnect added in v0.8.0

func (x *Command) GetConnect() *ConnectRequest

func (*Command) GetHistory added in v0.8.0

func (x *Command) GetHistory() *HistoryRequest

func (*Command) GetId added in v0.4.1

func (x *Command) GetId() uint32

func (*Command) GetPing added in v0.8.0

func (x *Command) GetPing() *PingRequest

func (*Command) GetPresence added in v0.8.0

func (x *Command) GetPresence() *PresenceRequest

func (*Command) GetPresenceStats added in v0.8.0

func (x *Command) GetPresenceStats() *PresenceStatsRequest

func (*Command) GetPublish added in v0.8.0

func (x *Command) GetPublish() *PublishRequest

func (*Command) GetRefresh added in v0.8.0

func (x *Command) GetRefresh() *RefreshRequest

func (*Command) GetRpc added in v0.8.0

func (x *Command) GetRpc() *RPCRequest

func (*Command) GetSend added in v0.8.0

func (x *Command) GetSend() *SendRequest

func (*Command) GetSubRefresh added in v0.8.0

func (x *Command) GetSubRefresh() *SubRefreshRequest

func (*Command) GetSubscribe added in v0.8.0

func (x *Command) GetSubscribe() *SubscribeRequest

func (*Command) GetUnsubscribe added in v0.8.0

func (x *Command) GetUnsubscribe() *UnsubscribeRequest

func (*Command) MarshalCF added in v0.23.0

func (m *Command) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Command) MarshalToCF added in v0.23.0

func (m *Command) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Command) MarshalToSizedBufferCF added in v0.23.0

func (m *Command) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Command) ProtoMessage

func (*Command) ProtoMessage()

func (*Command) ProtoReflect added in v0.7.0

func (x *Command) ProtoReflect() protoreflect.Message

func (*Command) Reset

func (x *Command) Reset()

func (*Command) SizeCF added in v0.23.0

func (m *Command) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Command) String

func (x *Command) String() string

func (*Command) UnmarshalCF added in v0.23.0

func (m *Command) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type CommandDecoder

type CommandDecoder interface {
	// Reset makes the decoder ready to decode commands from the given frame.
	Reset([]byte) error
	// Decode returns the next Command in the frame.
	Decode() (*Command, error)
}

CommandDecoder decodes commands from a transport frame which may contain several of them, see DataEncoder for the framing used.

Decode returns io.EOF together with the last successfully decoded Command, so a non-nil Command must be handled even when an error is returned:

for {
	cmd, err := decoder.Decode()
	if cmd != nil {
		// Handle the command.
	}
	if err != nil {
		// io.EOF means the frame is fully processed.
		break
	}
}

A CommandDecoder is not safe for concurrent use. Use GetCommandDecoder and PutCommandDecoder to take one from a pool and return it back when done.

func GetCommandDecoder

func GetCommandDecoder(protoType Type, data []byte) CommandDecoder

GetCommandDecoder returns a CommandDecoder for the given protocol type, taking it from a pool and resetting it to the given frame. Return it with PutCommandDecoder once the frame is fully processed. Any type other than TypeJSON is treated as TypeProtobuf.

Example

A single transport frame may contain several commands: in JSON they are separated by a `\n` delimiter, in Protobuf each command is prefixed with its length. Decoders take care of the framing, so the loop is the same for both.

package main

import (
	"errors"
	"fmt"
	"io"

	"github.com/centrifugal/protocol"
)

func main() {
	frame := []byte(`{"id":1,"connect":{"name":"go"}}
{"id":2,"subscribe":{"channel":"news"}}`)

	decoder := protocol.GetCommandDecoder(protocol.TypeJSON, frame)
	defer protocol.PutCommandDecoder(protocol.TypeJSON, decoder)

	for {
		cmd, err := decoder.Decode()
		if cmd != nil {
			// Server takes the first non-null request out of a Command.
			switch {
			case cmd.Connect != nil:
				fmt.Println(cmd.Id, protocol.FrameTypeConnect, cmd.Connect.Name)
			case cmd.Subscribe != nil:
				fmt.Println(cmd.Id, protocol.FrameTypeSubscribe, cmd.Subscribe.Channel)
			}
		}
		if err != nil {
			if !errors.Is(err, io.EOF) {
				fmt.Println("decode error:", err)
			}
			break
		}
	}
}
Output:
1 connect go
2 subscribe news

type CommandEncoder

type CommandEncoder interface {
	Encode(cmd *Command) ([]byte, error)
}

CommandEncoder encodes Command to bytes. It's the client-side counterpart of CommandDecoder.

type Connect added in v0.4.0

type Connect struct {
	Client  string                      `protobuf:"bytes,1,opt,name=client,proto3" json:"client,omitempty"`
	Version string                      `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
	Data    Raw                         `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	Subs    map[string]*SubscribeResult `` /* 135-byte string literal not displayed */
	Expires bool                        `protobuf:"varint,5,opt,name=expires,proto3" json:"expires,omitempty"`
	Ttl     uint32                      `protobuf:"varint,6,opt,name=ttl,proto3" json:"ttl,omitempty"`
	Ping    uint32                      `protobuf:"varint,7,opt,name=ping,proto3" json:"ping,omitempty"`
	// Never set on unidirectional transports: the client can not send a pong.
	Pong    bool   `protobuf:"varint,8,opt,name=pong,proto3" json:"pong,omitempty"`
	Session string `protobuf:"bytes,9,opt,name=session,proto3" json:"session,omitempty"`
	Node    string `protobuf:"bytes,10,opt,name=node,proto3" json:"node,omitempty"`
	// Server time as Unix timestamp in milliseconds (not sent by default).
	Time int64 `protobuf:"varint,11,opt,name=time,proto3" json:"time,omitempty"`
	// contains filtered or unexported fields
}

Connect is the first push on unidirectional transports, it is the equivalent of ConnectResult. See ConnectResult for field descriptions.

func (*Connect) AppendJSON added in v0.23.0

func (m *Connect) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Connect) DecodeJSON added in v0.23.0

func (m *Connect) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Connect) Descriptor deprecated added in v0.4.0

func (*Connect) Descriptor() ([]byte, []int)

Deprecated: Use Connect.ProtoReflect.Descriptor instead.

func (*Connect) GetClient added in v0.4.0

func (x *Connect) GetClient() string

func (*Connect) GetData added in v0.7.0

func (x *Connect) GetData() []byte

func (*Connect) GetExpires added in v0.6.0

func (x *Connect) GetExpires() bool

func (*Connect) GetNode added in v0.8.5

func (x *Connect) GetNode() string

func (*Connect) GetPing added in v0.8.2

func (x *Connect) GetPing() uint32

func (*Connect) GetPong added in v0.8.3

func (x *Connect) GetPong() bool

func (*Connect) GetSession added in v0.8.4

func (x *Connect) GetSession() string

func (*Connect) GetSubs added in v0.4.0

func (x *Connect) GetSubs() map[string]*SubscribeResult

func (*Connect) GetTime added in v0.13.1

func (x *Connect) GetTime() int64

func (*Connect) GetTtl added in v0.6.0

func (x *Connect) GetTtl() uint32

func (*Connect) GetVersion added in v0.4.0

func (x *Connect) GetVersion() string

func (*Connect) MarshalCF added in v0.23.0

func (m *Connect) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Connect) MarshalToCF added in v0.23.0

func (m *Connect) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Connect) MarshalToSizedBufferCF added in v0.23.0

func (m *Connect) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Connect) ProtoMessage added in v0.4.0

func (*Connect) ProtoMessage()

func (*Connect) ProtoReflect added in v0.7.0

func (x *Connect) ProtoReflect() protoreflect.Message

func (*Connect) Reset added in v0.4.0

func (x *Connect) Reset()

func (*Connect) SizeCF added in v0.23.0

func (m *Connect) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Connect) String added in v0.4.0

func (x *Connect) String() string

func (*Connect) UnmarshalCF added in v0.23.0

func (m *Connect) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type ConnectRequest

type ConnectRequest struct {

	// Connection token (JWT in Centrifugo), optional if the server can
	// authenticate the connection in another way.
	Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
	// Optional custom data passed to the application connect handler.
	Data Raw `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	// Server-side subscriptions the client wants to restore, keyed by channel.
	// Only recover, epoch, offset and delta of each SubscribeRequest are used -
	// they let the server recover publications the client missed since its
	// last known position. The server decides which subscriptions are granted.
	Subs map[string]*SubscribeRequest `` /* 135-byte string literal not displayed */
	// Name of the client SDK or application.
	Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`
	// Version of the client SDK or application.
	Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"`
	// Custom headers to pass to the server. Used when a transport does not
	// allow setting HTTP headers (e.g. WebSocket in a browser), the application
	// decides how to use them.
	Headers map[string]string `` /* 141-byte string literal not displayed */
	// Connection level features this client supports, as a bitmask. The server
	// replies with the subset it enabled in ConnectResult.flag.
	//
	//	1 << 0  dictionary compression, see Dictionary.
	Flag int64 `protobuf:"varint,7,opt,name=flag,proto3" json:"flag,omitempty"`
	// Application context this connection belongs to - which view, screen or
	// client kind it is. Connections sharing a profile see traffic of a similar
	// shape.
	//
	// Untrusted: the server may override it, and features built on it must treat
	// it as a hint rather than an assertion.
	Profile string `protobuf:"bytes,9,opt,name=profile,proto3" json:"profile,omitempty"`
	// Id of the compression dictionary this client already holds, so the server
	// can name it instead of sending it again.
	//
	// The server answers with a Dictionary carrying only an id when it recognises
	// this one, and with the full content otherwise - so an unknown id is a cache
	// miss rather than an error.
	//
	// An id is a hash of the dictionary content, so this id and the server's copy
	// are byte identical by construction: a dictionary that changes gets a new id
	// automatically.
	//
	// Deliberately one, not a list. A client caches the last dictionary it was
	// given, which is the one it needs when reconnecting to the same profile. The
	// cost is one extra transfer per hop during a rolling deploy where nodes
	// disagree, which is bounded and small.
	Dict string `protobuf:"bytes,8,opt,name=dict,proto3" json:"dict,omitempty"`
	// contains filtered or unexported fields
}

ConnectRequest authenticates a connection. It must be the first command sent by a client.

func (*ConnectRequest) AppendJSON added in v0.23.0

func (m *ConnectRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*ConnectRequest) DecodeJSON added in v0.23.0

func (m *ConnectRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*ConnectRequest) Descriptor deprecated

func (*ConnectRequest) Descriptor() ([]byte, []int)

Deprecated: Use ConnectRequest.ProtoReflect.Descriptor instead.

func (*ConnectRequest) GetData added in v0.7.0

func (x *ConnectRequest) GetData() []byte

func (*ConnectRequest) GetDict added in v0.21.0

func (x *ConnectRequest) GetDict() string

func (*ConnectRequest) GetFlag added in v0.17.0

func (x *ConnectRequest) GetFlag() int64

func (*ConnectRequest) GetHeaders added in v0.14.0

func (x *ConnectRequest) GetHeaders() map[string]string

func (*ConnectRequest) GetName added in v0.3.4

func (x *ConnectRequest) GetName() string

func (*ConnectRequest) GetProfile added in v0.21.0

func (x *ConnectRequest) GetProfile() string

func (*ConnectRequest) GetSubs

func (x *ConnectRequest) GetSubs() map[string]*SubscribeRequest

func (*ConnectRequest) GetToken

func (x *ConnectRequest) GetToken() string

func (*ConnectRequest) GetVersion added in v0.3.4

func (x *ConnectRequest) GetVersion() string

func (*ConnectRequest) MarshalCF added in v0.23.0

func (m *ConnectRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*ConnectRequest) MarshalToCF added in v0.23.0

func (m *ConnectRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*ConnectRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *ConnectRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*ConnectRequest) ProtoMessage

func (*ConnectRequest) ProtoMessage()

func (*ConnectRequest) ProtoReflect added in v0.7.0

func (x *ConnectRequest) ProtoReflect() protoreflect.Message

func (*ConnectRequest) Reset

func (x *ConnectRequest) Reset()

func (*ConnectRequest) SizeCF added in v0.23.0

func (m *ConnectRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*ConnectRequest) String

func (x *ConnectRequest) String() string

func (*ConnectRequest) UnmarshalCF added in v0.23.0

func (m *ConnectRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type ConnectResult

type ConnectResult struct {

	// Unique client (connection) id assigned by the server.
	Client string `protobuf:"bytes,1,opt,name=client,proto3" json:"client,omitempty"`
	// Server version.
	Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
	// When set the connection expires and the client must send RefreshRequest
	// with a new token before ttl elapses.
	Expires bool `protobuf:"varint,3,opt,name=expires,proto3" json:"expires,omitempty"`
	// Seconds until the connection expires.
	Ttl uint32 `protobuf:"varint,4,opt,name=ttl,proto3" json:"ttl,omitempty"`
	// Optional custom data returned by the application connect handler.
	Data Raw `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
	// Server-side subscriptions of the connection, keyed by channel.
	Subs map[string]*SubscribeResult `` /* 135-byte string literal not displayed */
	// Server ping interval in seconds, zero when the server does not send pings.
	// The client may consider the connection lost if no data (including pings)
	// arrived from the server for noticeably longer than this interval.
	Ping uint32 `protobuf:"varint,7,opt,name=ping,proto3" json:"ping,omitempty"`
	// When set the client must respond to every server ping (empty Reply) with
	// a pong (empty Command), otherwise the server closes the connection.
	Pong bool `protobuf:"varint,8,opt,name=pong,proto3" json:"pong,omitempty"`
	// Session of the connection, set for unidirectional transports and for
	// bidirectional emulation, see EmulationRequest.session.
	Session string `protobuf:"bytes,9,opt,name=session,proto3" json:"session,omitempty"`
	// Id of the node serving the connection, set for bidirectional emulation,
	// see EmulationRequest.node.
	Node string `protobuf:"bytes,10,opt,name=node,proto3" json:"node,omitempty"`
	// Server time as Unix timestamp in milliseconds (not sent by default).
	Time int64 `protobuf:"varint,11,opt,name=time,proto3" json:"time,omitempty"`
	// Connection level features the server actually enabled, using the same bits
	// as ConnectRequest.flag. A client can not assume a feature it advertised was
	// accepted - the server may have it disabled, or may decline per connection -
	// so this is how it finds out.
	Flag int64 `protobuf:"varint,12,opt,name=flag,proto3" json:"flag,omitempty"`
	// Compression dictionary for this connection, when the server enabled
	// dictionary compression.
	//
	// It travels in the connect reply rather than a push so there is no ordering
	// rule to get wrong: this frame is raw, and every frame after it is
	// compressed. It carries only an id when the client advertised that same id in
	// ConnectRequest.dict, since the client already holds the bytes.
	Dict *Dictionary `protobuf:"bytes,13,opt,name=dict,proto3" json:"dict,omitempty"`
	// contains filtered or unexported fields
}

ConnectResult is the result of a successful connect.

func (*ConnectResult) AppendJSON added in v0.23.0

func (m *ConnectResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*ConnectResult) DecodeJSON added in v0.23.0

func (m *ConnectResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*ConnectResult) Descriptor deprecated

func (*ConnectResult) Descriptor() ([]byte, []int)

Deprecated: Use ConnectResult.ProtoReflect.Descriptor instead.

func (*ConnectResult) GetClient

func (x *ConnectResult) GetClient() string

func (*ConnectResult) GetData added in v0.7.0

func (x *ConnectResult) GetData() []byte

func (*ConnectResult) GetDict added in v0.21.0

func (x *ConnectResult) GetDict() *Dictionary

func (*ConnectResult) GetExpires

func (x *ConnectResult) GetExpires() bool

func (*ConnectResult) GetFlag added in v0.21.0

func (x *ConnectResult) GetFlag() int64

func (*ConnectResult) GetNode added in v0.8.5

func (x *ConnectResult) GetNode() string

func (*ConnectResult) GetPing added in v0.8.2

func (x *ConnectResult) GetPing() uint32

func (*ConnectResult) GetPong added in v0.8.3

func (x *ConnectResult) GetPong() bool

func (*ConnectResult) GetSession added in v0.8.4

func (x *ConnectResult) GetSession() string

func (*ConnectResult) GetSubs

func (x *ConnectResult) GetSubs() map[string]*SubscribeResult

func (*ConnectResult) GetTime added in v0.13.0

func (x *ConnectResult) GetTime() int64

func (*ConnectResult) GetTtl added in v0.4.1

func (x *ConnectResult) GetTtl() uint32

func (*ConnectResult) GetVersion

func (x *ConnectResult) GetVersion() string

func (*ConnectResult) MarshalCF added in v0.23.0

func (m *ConnectResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*ConnectResult) MarshalToCF added in v0.23.0

func (m *ConnectResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*ConnectResult) MarshalToSizedBufferCF added in v0.23.0

func (m *ConnectResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*ConnectResult) ProtoMessage

func (*ConnectResult) ProtoMessage()

func (*ConnectResult) ProtoReflect added in v0.7.0

func (x *ConnectResult) ProtoReflect() protoreflect.Message

func (*ConnectResult) Reset

func (x *ConnectResult) Reset()

func (*ConnectResult) SizeCF added in v0.23.0

func (m *ConnectResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*ConnectResult) String

func (x *ConnectResult) String() string

func (*ConnectResult) UnmarshalCF added in v0.23.0

func (m *ConnectResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type DataEncoder added in v0.4.0

type DataEncoder interface {
	// Reset prepares the encoder to build a new frame, dropping everything
	// encoded so far.
	Reset()
	// Encode appends an already encoded message to the frame.
	Encode([]byte) error
	// Finish returns a copy of the frame built so far.
	Finish() []byte
	// FinishNoCopy returns the frame built so far without copying it. The
	// returned slice is only valid until the next Reset or Encode call, so use
	// it only if the data is written to a connection before that happens.
	FinishNoCopy() []byte
}

DataEncoder concatenates already encoded messages into a single transport frame, applying the framing of a concrete protocol Type: messages are separated by a `\n` delimiter in JSON and prefixed with their length in Protobuf.

A DataEncoder is not safe for concurrent use. Use GetDataEncoder and PutDataEncoder to take one from a pool and return it back when done.

func GetDataEncoder added in v0.4.0

func GetDataEncoder(protoType Type) DataEncoder

GetDataEncoder returns a DataEncoder for the given protocol type, taking it from a pool and resetting it. Return it with PutDataEncoder once the frame is built. Any type other than TypeJSON is treated as TypeProtobuf.

type DeflateFrameCodec added in v0.21.0

type DeflateFrameCodec struct {
	// contains filtered or unexported fields
}

DeflateFrameCodec compresses and decompresses whole transport frames with DEFLATE against a shared preset dictionary, applying the frame marker convention above.

It lives in this package because a server and a client have to agree on it byte for byte, and this package is the only thing they both import - putting it anywhere else would let the two sides drift. It is not an abstraction over codecs: it is the one codec the protocol ships with. A second algorithm would be a sibling type emitting the same markers, not an implementation of an interface here, since which codec a connection uses is settled by capability flags at connect rather than by anything on the wire.

One codec is meant to be shared by every connection using the same dictionary, and it is safe for concurrent use. This matters: a DEFLATE writer retains several hundred kilobytes of window and hash state, so giving each connection its own would dwarf the rest of a connection's footprint. Pooling them behind a shared codec keeps that cost proportional to the number of concurrent writes instead of the number of connections.

func NewDeflateFrameCodec added in v0.21.0

func NewDeflateFrameCodec(id string, dict []byte, level int) *DeflateFrameCodec

NewDeflateFrameCodec builds a codec for the given dictionary. id identifies the dictionary content so both sides can tell which one a frame was built with.

level is a DEFLATE compression level from MinDictionaryCompressionLevel to 9. It affects only how hard this side's encoder works to shrink a frame, and never needs to match what the other side of a connection uses: DEFLATE's format is self-describing per block, so a decoder never depends on which level produced its input, only on sharing the same dictionary. NewDeflateFrameCodec panics if level is below MinDictionaryCompressionLevel, since that silently disables the dictionary rather than trading ratio for speed.

This package does not recommend one level for every caller, because the right choice depends on traffic and dictionary shapes only the caller sees, and it has already moved once as compress/flate itself changed. Measured on go1.26.5 and go1.27.0, frames drawn from the vocabulary a dictionary is built from, against a few KB dictionary:

  • go1.26: levels 2-9 are byte-identical in output and cost, because a per-frame compression there is dominated by loading the dictionary on Reset, not by encoding the frame - the level only governs the smaller half of the work.
  • go1.27 rewrote compress/flate's levels 2-6 into new encoders optimised for large-payload throughput (golang/go#75532), at the cost of ratio for a small payload against a large preset dictionary - exactly this codec's shape. A 40 byte frame against a 2.4KB dictionary compresses to 47 bytes at level 6 on go1.27 (worse than sending it raw) versus 34 bytes on go1.26. Levels 7-9 kept the old algorithm, so they are unaffected: 31 bytes on either Go version, at a CPU cost within a few percent of what level 6 cost on go1.26 - i.e. level 7 on go1.27 tracks the historical level-6 cost/ratio, where level 6 on go1.27 does not.
  • Levels 7, 8 and 9 produce byte-identical output for this shape, so 9 buys nothing over 7 and only costs more CPU for a caller with this shape of traffic.

func (*DeflateFrameCodec) Compress added in v0.21.0

func (c *DeflateFrameCodec) Compress(dst, src []byte) []byte

Compress encodes src into a framed payload appended to dst.

It falls back to FrameCodecRaw whenever compression does not actually shrink the frame, so an incompressible payload - already compressed data, encrypted blobs - costs one marker byte instead of growing.

func (*DeflateFrameCodec) Decompress added in v0.21.0

func (c *DeflateFrameCodec) Decompress(dst, frame []byte, maxSize int) ([]byte, error)

Decompress decodes a framed payload produced by Compress, appending the result to dst. maxSize bounds the decompressed output, pass 0 to leave it unbounded.

func (*DeflateFrameCodec) Dict added in v0.21.0

func (c *DeflateFrameCodec) Dict() []byte

Dict returns the raw dictionary bytes. The result must not be modified.

func (*DeflateFrameCodec) ID added in v0.21.0

func (c *DeflateFrameCodec) ID() string

ID returns the dictionary identifier this codec was built for.

type Dictionary added in v0.21.0

type Dictionary struct {

	// Identifier of dictionary content, client may cache by it.
	//
	// It is SHA-256 of the content, first 12 bytes, base64url without padding.
	//
	// The derivation is fixed rather than conventional, because a client that
	// keeps a dictionary between connections hashes the bytes it stored against
	// this id before reusing them. Storage shared with anything else on the
	// client's origin can be rewritten, and DEFLATE back references resolve into
	// the dictionary - so substituted content does not corrupt a frame, it makes
	// a genuine server frame decode into whatever the substituter chose. Only an
	// id the server issued detects that: a checksum the client stored alongside
	// would simply be rewritten with the bytes.
	//
	// A server identifying dictionaries some other way is not rejected. It has
	// every caching client quietly stop caching instead, which is worse.
	//
	// It also means one id can never name two different dictionaries, so a client
	// reconnecting to a node that built its own gets an exact match or a miss,
	// never the wrong bytes.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The dictionary content, always DEFLATE compressed. Inflate it with no preset
	// dictionary before use.
	//
	// It is compressed because it arrives in the connect reply, which cannot be
	// compressed at the frame level - nothing is installed yet to compress it
	// against. Compressing the content instead is worth about 8x on JSON, and a
	// dictionary is sampled message text so it always compresses.
	//
	// data is set on Protobuf connections, where bytes travel directly. data_b64
	// is set on JSON connections, where a bytes field carries raw JSON and cannot
	// hold binary - it is standard base64 with padding of the same compressed
	// content. Exactly one of them is set, and neither when the server is naming
	// a dictionary the client already holds.
	Data    Raw    `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	DataB64 string `protobuf:"bytes,3,opt,name=data_b64,json=dataB64,proto3" json:"data_b64,omitempty"`
	// contains filtered or unexported fields
}

Dictionary is a shared compression dictionary the server asks the client to use for subsequent frames on this connection. It arrives in the connect reply, and every frame after that reply starts with a one byte codec marker saying whether it was compressed.

func (*Dictionary) AppendJSON added in v0.23.0

func (m *Dictionary) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Dictionary) DecodeJSON added in v0.23.0

func (m *Dictionary) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Dictionary) Descriptor deprecated added in v0.21.0

func (*Dictionary) Descriptor() ([]byte, []int)

Deprecated: Use Dictionary.ProtoReflect.Descriptor instead.

func (*Dictionary) GetData added in v0.21.0

func (x *Dictionary) GetData() []byte

func (*Dictionary) GetDataB64 added in v0.21.0

func (x *Dictionary) GetDataB64() string

func (*Dictionary) GetId added in v0.21.0

func (x *Dictionary) GetId() string

func (*Dictionary) MarshalCF added in v0.23.0

func (m *Dictionary) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Dictionary) MarshalToCF added in v0.23.0

func (m *Dictionary) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Dictionary) MarshalToSizedBufferCF added in v0.23.0

func (m *Dictionary) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Dictionary) ProtoMessage added in v0.21.0

func (*Dictionary) ProtoMessage()

func (*Dictionary) ProtoReflect added in v0.21.0

func (x *Dictionary) ProtoReflect() protoreflect.Message

func (*Dictionary) Reset added in v0.21.0

func (x *Dictionary) Reset()

func (*Dictionary) SizeCF added in v0.23.0

func (m *Dictionary) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Dictionary) String added in v0.21.0

func (x *Dictionary) String() string

func (*Dictionary) UnmarshalCF added in v0.23.0

func (m *Dictionary) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type Disconnect added in v0.4.0

type Disconnect struct {

	// Disconnect code, see the code ranges above.
	Code uint32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	// Human readable reason. Less than 127 bytes due to WebSocket close frame
	// limitations.
	Reason string `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"`
	// Deprecated: not set by the current server. Clients decide whether to
	// reconnect based on code.
	Reconnect bool `protobuf:"varint,3,opt,name=reconnect,proto3" json:"reconnect,omitempty"`
	// contains filtered or unexported fields
}

Disconnect is sent when the server closes the connection.

Code ranges:

[0, 2999]    reserved for client-side and transport specific needs.
[3000, 3499] reserved by Centrifuge, client should reconnect.
[3500, 3999] reserved by Centrifuge, terminal - client must not reconnect.
[4000, 4499] application codes, client should reconnect.
[4500, 4999] application codes, terminal - client must not reconnect.
>= 5000      reserved by Centrifuge, client should reconnect.

func (*Disconnect) AppendJSON added in v0.23.0

func (m *Disconnect) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Disconnect) DecodeJSON added in v0.23.0

func (m *Disconnect) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Disconnect) Descriptor deprecated added in v0.4.0

func (*Disconnect) Descriptor() ([]byte, []int)

Deprecated: Use Disconnect.ProtoReflect.Descriptor instead.

func (*Disconnect) GetCode added in v0.4.0

func (x *Disconnect) GetCode() uint32

func (*Disconnect) GetReason added in v0.4.0

func (x *Disconnect) GetReason() string

func (*Disconnect) GetReconnect added in v0.4.0

func (x *Disconnect) GetReconnect() bool

func (*Disconnect) MarshalCF added in v0.23.0

func (m *Disconnect) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Disconnect) MarshalToCF added in v0.23.0

func (m *Disconnect) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Disconnect) MarshalToSizedBufferCF added in v0.23.0

func (m *Disconnect) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Disconnect) ProtoMessage added in v0.4.0

func (*Disconnect) ProtoMessage()

func (*Disconnect) ProtoReflect added in v0.7.0

func (x *Disconnect) ProtoReflect() protoreflect.Message

func (*Disconnect) Reset added in v0.4.0

func (x *Disconnect) Reset()

func (*Disconnect) SizeCF added in v0.23.0

func (m *Disconnect) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Disconnect) String added in v0.4.0

func (x *Disconnect) String() string

func (*Disconnect) UnmarshalCF added in v0.23.0

func (m *Disconnect) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type EmulationRequest added in v0.8.5

type EmulationRequest struct {

	// Id of the node serving the connection, from ConnectResult.node.
	Node string `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"`
	// Session of the connection, from ConnectResult.session.
	Session string `protobuf:"bytes,2,opt,name=session,proto3" json:"session,omitempty"`
	// Encoded Command(s) in the connection protocol, may contain several
	// commands in the same format as a regular transport frame. For JSON this
	// is a JSON string containing the encoded commands, for Protobuf - raw bytes.
	Data Raw `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

EmulationRequest is the body of an HTTP request a client sends to the emulation endpoint when it uses bidirectional emulation over a transport which can only stream data from server to client (HTTP-streaming, SSE). Server-to-client data flows over the stream, while client commands are delivered with EmulationRequest and routed to the node which holds the connection.

The request body is Protobuf when sent with Content-Type application/octet-stream, JSON otherwise. The server responds with HTTP 204 No Content on success - replies to commands arrive over the stream.

func (*EmulationRequest) AppendJSON added in v0.23.0

func (m *EmulationRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*EmulationRequest) DecodeJSON added in v0.23.0

func (m *EmulationRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*EmulationRequest) Descriptor deprecated added in v0.8.5

func (*EmulationRequest) Descriptor() ([]byte, []int)

Deprecated: Use EmulationRequest.ProtoReflect.Descriptor instead.

func (*EmulationRequest) GetData added in v0.8.5

func (x *EmulationRequest) GetData() []byte

func (*EmulationRequest) GetNode added in v0.8.5

func (x *EmulationRequest) GetNode() string

func (*EmulationRequest) GetSession added in v0.8.5

func (x *EmulationRequest) GetSession() string

func (*EmulationRequest) MarshalCF added in v0.23.0

func (m *EmulationRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*EmulationRequest) MarshalToCF added in v0.23.0

func (m *EmulationRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*EmulationRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *EmulationRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*EmulationRequest) ProtoMessage added in v0.8.5

func (*EmulationRequest) ProtoMessage()

func (*EmulationRequest) ProtoReflect added in v0.8.5

func (x *EmulationRequest) ProtoReflect() protoreflect.Message

func (*EmulationRequest) Reset added in v0.8.5

func (x *EmulationRequest) Reset()

func (*EmulationRequest) SizeCF added in v0.23.0

func (m *EmulationRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*EmulationRequest) String added in v0.8.5

func (x *EmulationRequest) String() string

func (*EmulationRequest) UnmarshalCF added in v0.23.0

func (m *EmulationRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type Error

type Error struct {

	// Error code.
	Code uint32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	// Human readable error description. Clients must not rely on its content,
	// use code instead.
	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	// When set the error condition is temporary and the same command may succeed
	// if retried later (preferably with a backoff).
	Temporary bool `protobuf:"varint,3,opt,name=temporary,proto3" json:"temporary,omitempty"`
	// contains filtered or unexported fields
}

Error is returned in Reply to a Command which could not be processed.

Codes in range [0, 399] are reserved by Centrifuge, applications use codes in range [400, 1999]. Built-in codes:

100 internal server error (temporary)
101 unauthorized
102 unknown channel
103 permission denied
104 method not found
105 already subscribed
106 limit exceeded
107 bad request
108 not available
109 token expired
110 expired
111 too many requests (temporary)
112 unrecoverable position
113 concurrent pagination (temporary)

Note that many protocol violations result in a Disconnect instead of an Error reply.

func (*Error) AppendJSON added in v0.23.0

func (m *Error) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Error) DecodeJSON added in v0.23.0

func (m *Error) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Error) Descriptor deprecated

func (*Error) Descriptor() ([]byte, []int)

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) GetCode

func (x *Error) GetCode() uint32

func (*Error) GetMessage

func (x *Error) GetMessage() string

func (*Error) GetTemporary added in v0.8.5

func (x *Error) GetTemporary() bool

func (*Error) MarshalCF added in v0.23.0

func (m *Error) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Error) MarshalToCF added in v0.23.0

func (m *Error) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Error) MarshalToSizedBufferCF added in v0.23.0

func (m *Error) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect added in v0.7.0

func (x *Error) ProtoReflect() protoreflect.Message

func (*Error) Reset

func (x *Error) Reset()

func (*Error) SizeCF added in v0.23.0

func (m *Error) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Error) String

func (x *Error) String() string

func (*Error) UnmarshalCF added in v0.23.0

func (m *Error) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type FilterNode added in v0.17.0

type FilterNode struct {

	// Operation type for this node:
	// - "" (empty string) → leaf node (comparison)
	// - "and" → logical AND of child nodes (at least one)
	// - "or"  → logical OR of child nodes (at least one)
	// - "not" → logical NOT of a single child node
	Op string `protobuf:"bytes,1,opt,name=op,proto3" json:"op,omitempty"`
	// Tag key for comparison (only valid for leaf nodes). Required for all
	// comparisons except "ex" and "nex".
	Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
	// Comparison operator for leaf nodes.
	// Only meaningful if op == "".
	// Supported values:
	//
	//	"eq"   → equal
	//	"neq"  → not equal
	//	"in"   → value is in vals
	//	"nin"  → value is not in vals
	//	"ex"   → key exists in tags
	//	"nex"  → key does not exist
	//	"sw"   → string starts with val
	//	"ew"   → string ends with val
	//	"ct"   → string contains val
	//	"lt"   → numeric less than val
	//	"lte"  → numeric less than or equal val
	//	"gt"   → numeric greater than val
	//	"gte"  → numeric greater than or equal val
	//
	// A missing tag never matches eq, sw, ew, ct and numeric comparisons, and
	// always matches neq. For in and nin a missing tag is compared as an empty
	// string. Numeric comparisons parse both sides as decimal numbers and do not
	// match when either side is not a number.
	Cmp string `protobuf:"bytes,3,opt,name=cmp,proto3" json:"cmp,omitempty"`
	// Single value used in most comparisons (e.g. "eq"). Required for all
	// comparisons except "in", "nin", "ex" and "nex".
	Val string `protobuf:"bytes,4,opt,name=val,proto3" json:"val,omitempty"`
	// Multiple values used for set comparisons ("in", "nin"), required for them.
	Vals []string `protobuf:"bytes,5,rep,name=vals,proto3" json:"vals,omitempty"`
	// Child nodes.
	// Used for logical operations: "and", "or", "not".
	Nodes []*FilterNode `protobuf:"bytes,6,rep,name=nodes,proto3" json:"nodes,omitempty"`
	// contains filtered or unexported fields
}

FilterNode is a node of a publication tags filter expression tree, see SubscribeRequest.tf.

func (*FilterNode) AppendJSON added in v0.23.0

func (m *FilterNode) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*FilterNode) DecodeJSON added in v0.23.0

func (m *FilterNode) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*FilterNode) Descriptor deprecated added in v0.17.0

func (*FilterNode) Descriptor() ([]byte, []int)

Deprecated: Use FilterNode.ProtoReflect.Descriptor instead.

func (*FilterNode) GetCmp added in v0.17.0

func (x *FilterNode) GetCmp() string

func (*FilterNode) GetKey added in v0.17.0

func (x *FilterNode) GetKey() string

func (*FilterNode) GetNodes added in v0.17.0

func (x *FilterNode) GetNodes() []*FilterNode

func (*FilterNode) GetOp added in v0.17.0

func (x *FilterNode) GetOp() string

func (*FilterNode) GetVal added in v0.17.0

func (x *FilterNode) GetVal() string

func (*FilterNode) GetVals added in v0.17.0

func (x *FilterNode) GetVals() []string

func (*FilterNode) MarshalCF added in v0.23.0

func (m *FilterNode) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*FilterNode) MarshalToCF added in v0.23.0

func (m *FilterNode) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*FilterNode) MarshalToSizedBufferCF added in v0.23.0

func (m *FilterNode) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*FilterNode) ProtoMessage added in v0.17.0

func (*FilterNode) ProtoMessage()

func (*FilterNode) ProtoReflect added in v0.17.0

func (x *FilterNode) ProtoReflect() protoreflect.Message

func (*FilterNode) Reset added in v0.17.0

func (x *FilterNode) Reset()

func (*FilterNode) SizeCF added in v0.23.0

func (m *FilterNode) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*FilterNode) String added in v0.17.0

func (x *FilterNode) String() string

func (*FilterNode) UnmarshalCF added in v0.23.0

func (m *FilterNode) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type FrameType added in v0.11.0

type FrameType uint8

FrameType describes the type of a protocol frame. It's not a part of the wire format – it's used for observability, so that a server may count and measure frames it sends and receives per type.

const (
	FrameTypeServerPing FrameType = iota + 1
	FrameTypeClientPong

	FrameTypePushConnect
	FrameTypePushSubscribe
	FrameTypePushPublication
	FrameTypePushJoin
	FrameTypePushLeave
	FrameTypePushUnsubscribe
	FrameTypePushMessage
	FrameTypePushRefresh
	FrameTypePushDisconnect

	FrameTypeConnect
	FrameTypeSubscribe
	FrameTypePublish
	FrameTypeUnsubscribe
	FrameTypeRPC
	FrameTypePresence
	FrameTypePresenceStats
	FrameTypeHistory
	FrameTypeRefresh
	FrameTypeSubRefresh
	FrameTypeSend
)

Frame types of the protocol: a ping/pong pair, asynchronous server-to-client pushes and client-to-server commands.

func (FrameType) String added in v0.11.0

func (f FrameType) String() string

String returns a snake_case name of the frame type, suitable for using as a metric label. It returns "unknown" for frame types not defined in this package.

type HistoryRequest

type HistoryRequest struct {

	// Channel to get history of, required.
	Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
	// Maximum number of publications to return. Zero returns no publications,
	// only the current stream position. -1 returns all publications. The server
	// may cap it with its configured limit.
	Limit int32 `protobuf:"varint,7,opt,name=limit,proto3" json:"limit,omitempty"`
	// Optional position to iterate from: publications after it are returned
	// (before it when reverse is set). An epoch mismatch results in error
	// 112 (unrecoverable position), a zero offset with reverse set - in error
	// 107 (bad request).
	Since *StreamPosition `protobuf:"bytes,8,opt,name=since,proto3" json:"since,omitempty"`
	// When set publications are returned from newest to oldest.
	Reverse bool `protobuf:"varint,9,opt,name=reverse,proto3" json:"reverse,omitempty"`
	// contains filtered or unexported fields
}

HistoryRequest asks for the publication history of a channel.

func (*HistoryRequest) AppendJSON added in v0.23.0

func (m *HistoryRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*HistoryRequest) DecodeJSON added in v0.23.0

func (m *HistoryRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*HistoryRequest) Descriptor deprecated

func (*HistoryRequest) Descriptor() ([]byte, []int)

Deprecated: Use HistoryRequest.ProtoReflect.Descriptor instead.

func (*HistoryRequest) GetChannel

func (x *HistoryRequest) GetChannel() string

func (*HistoryRequest) GetLimit added in v0.3.5

func (x *HistoryRequest) GetLimit() int32

func (*HistoryRequest) GetReverse added in v0.7.1

func (x *HistoryRequest) GetReverse() bool

func (*HistoryRequest) GetSince added in v0.6.0

func (x *HistoryRequest) GetSince() *StreamPosition

func (*HistoryRequest) MarshalCF added in v0.23.0

func (m *HistoryRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*HistoryRequest) MarshalToCF added in v0.23.0

func (m *HistoryRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*HistoryRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *HistoryRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*HistoryRequest) ProtoMessage

func (*HistoryRequest) ProtoMessage()

func (*HistoryRequest) ProtoReflect added in v0.7.0

func (x *HistoryRequest) ProtoReflect() protoreflect.Message

func (*HistoryRequest) Reset

func (x *HistoryRequest) Reset()

func (*HistoryRequest) SizeCF added in v0.23.0

func (m *HistoryRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*HistoryRequest) String

func (x *HistoryRequest) String() string

func (*HistoryRequest) UnmarshalCF added in v0.23.0

func (m *HistoryRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type HistoryResult

type HistoryResult struct {

	// Publications from the stream.
	Publications []*Publication `protobuf:"bytes,1,rep,name=publications,proto3" json:"publications"`
	// Current stream epoch.
	Epoch string `protobuf:"bytes,2,opt,name=epoch,proto3" json:"epoch"`
	// Current stream top offset.
	Offset uint64 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset"`
	// contains filtered or unexported fields
}

HistoryResult is the result of a history request.

func (*HistoryResult) AppendJSON added in v0.23.0

func (m *HistoryResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*HistoryResult) DecodeJSON added in v0.23.0

func (m *HistoryResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*HistoryResult) Descriptor deprecated

func (*HistoryResult) Descriptor() ([]byte, []int)

Deprecated: Use HistoryResult.ProtoReflect.Descriptor instead.

func (*HistoryResult) GetEpoch added in v0.3.5

func (x *HistoryResult) GetEpoch() string

func (*HistoryResult) GetOffset added in v0.3.5

func (x *HistoryResult) GetOffset() uint64

func (*HistoryResult) GetPublications

func (x *HistoryResult) GetPublications() []*Publication

func (*HistoryResult) MarshalCF added in v0.23.0

func (m *HistoryResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*HistoryResult) MarshalToCF added in v0.23.0

func (m *HistoryResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*HistoryResult) MarshalToSizedBufferCF added in v0.23.0

func (m *HistoryResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*HistoryResult) ProtoMessage

func (*HistoryResult) ProtoMessage()

func (*HistoryResult) ProtoReflect added in v0.7.0

func (x *HistoryResult) ProtoReflect() protoreflect.Message

func (*HistoryResult) Reset

func (x *HistoryResult) Reset()

func (*HistoryResult) SizeCF added in v0.23.0

func (m *HistoryResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*HistoryResult) String

func (x *HistoryResult) String() string

func (*HistoryResult) UnmarshalCF added in v0.23.0

func (m *HistoryResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type JSONCommandDecoder

type JSONCommandDecoder struct {
	// contains filtered or unexported fields
}

JSONCommandDecoder is a CommandDecoder for commands separated by a `\n` delimiter.

Decoding is zero-copy: string fields of the returned Command point into the frame passed to NewJSONCommandDecoder or Reset rather than into copies of it. The frame must therefore stay unmodified for as long as the decoded commands are used – do not hand decoded commands to another goroutine while reusing the read buffer they came from. Raw payload fields are copied and are not affected. The Protobuf decoders copy everything, so this applies to JSON only.

func NewJSONCommandDecoder

func NewJSONCommandDecoder(data []byte) *JSONCommandDecoder

NewJSONCommandDecoder creates a new JSONCommandDecoder for the given frame.

func (*JSONCommandDecoder) Decode

func (d *JSONCommandDecoder) Decode() (*Command, error)

Decode returns the next Command in the frame. The last Command is returned together with io.EOF, see the CommandDecoder interface.

func (*JSONCommandDecoder) Reset

func (d *JSONCommandDecoder) Reset(data []byte) error

Reset makes the decoder ready to decode commands from the given frame.

type JSONCommandEncoder

type JSONCommandEncoder struct {
}

JSONCommandEncoder is a CommandEncoder which encodes to JSON.

func NewJSONCommandEncoder

func NewJSONCommandEncoder() *JSONCommandEncoder

NewJSONCommandEncoder creates a new JSONCommandEncoder. It's safe to use the returned encoder concurrently.

func (*JSONCommandEncoder) Encode

func (e *JSONCommandEncoder) Encode(cmd *Command) ([]byte, error)

Encode Command to bytes. The result contains no framing: to send several commands in one frame join them with a `\n` delimiter, see JSONDataEncoder.

type JSONDataEncoder added in v0.4.0

type JSONDataEncoder struct {
	// contains filtered or unexported fields
}

JSONDataEncoder is a DataEncoder which separates messages by a `\n` delimiter.

func NewJSONDataEncoder added in v0.4.0

func NewJSONDataEncoder() *JSONDataEncoder

NewJSONDataEncoder creates a new JSONDataEncoder.

func (*JSONDataEncoder) Encode added in v0.4.0

func (e *JSONDataEncoder) Encode(data []byte) error

Encode appends an already encoded message to the frame, separating it from the previous one with a `\n` delimiter.

func (*JSONDataEncoder) Finish added in v0.4.0

func (e *JSONDataEncoder) Finish() []byte

Finish returns a copy of the frame built so far.

func (*JSONDataEncoder) FinishNoCopy added in v0.18.2

func (e *JSONDataEncoder) FinishNoCopy() []byte

FinishNoCopy returns the frame built so far without copying it, see the DataEncoder interface for the lifetime of the returned slice.

func (*JSONDataEncoder) Reset added in v0.4.0

func (e *JSONDataEncoder) Reset()

Reset prepares the encoder to build a new frame.

type JSONPushEncoder

type JSONPushEncoder struct {
}

JSONPushEncoder is a PushEncoder which encodes to JSON.

func NewJSONPushEncoder

func NewJSONPushEncoder() *JSONPushEncoder

NewJSONPushEncoder creates a new JSONPushEncoder. It's safe to use the returned encoder concurrently, see also DefaultJsonPushEncoder.

func (*JSONPushEncoder) Encode

func (e *JSONPushEncoder) Encode(message *Push) ([]byte, error)

Encode Push to bytes.

func (*JSONPushEncoder) EncodeConnect added in v0.4.0

func (e *JSONPushEncoder) EncodeConnect(message *Connect, reuse ...[]byte) ([]byte, error)

EncodeConnect to bytes.

func (*JSONPushEncoder) EncodeDisconnect added in v0.4.0

func (e *JSONPushEncoder) EncodeDisconnect(message *Disconnect, reuse ...[]byte) ([]byte, error)

EncodeDisconnect to bytes.

func (*JSONPushEncoder) EncodeJoin

func (e *JSONPushEncoder) EncodeJoin(message *Join, reuse ...[]byte) ([]byte, error)

EncodeJoin to bytes.

func (*JSONPushEncoder) EncodeLeave

func (e *JSONPushEncoder) EncodeLeave(message *Leave, reuse ...[]byte) ([]byte, error)

EncodeLeave to bytes.

func (*JSONPushEncoder) EncodeMessage

func (e *JSONPushEncoder) EncodeMessage(message *Message, reuse ...[]byte) ([]byte, error)

EncodeMessage to bytes.

func (*JSONPushEncoder) EncodePublication

func (e *JSONPushEncoder) EncodePublication(message *Publication, reuse ...[]byte) ([]byte, error)

EncodePublication to bytes.

func (*JSONPushEncoder) EncodeRefresh added in v0.6.0

func (e *JSONPushEncoder) EncodeRefresh(message *Refresh, reuse ...[]byte) ([]byte, error)

EncodeRefresh to bytes.

func (*JSONPushEncoder) EncodeSubscribe added in v0.4.0

func (e *JSONPushEncoder) EncodeSubscribe(message *Subscribe, reuse ...[]byte) ([]byte, error)

EncodeSubscribe to bytes.

func (*JSONPushEncoder) EncodeUnsubscribe added in v0.4.0

func (e *JSONPushEncoder) EncodeUnsubscribe(message *Unsubscribe, reuse ...[]byte) ([]byte, error)

EncodeUnsubscribe to bytes.

type JSONReplyDecoder

type JSONReplyDecoder struct {
	// contains filtered or unexported fields
}

JSONReplyDecoder is a ReplyDecoder which reads a stream of JSON replies, such as the `\n` separated frame produced by JSONDataEncoder.

func NewJSONReplyDecoder

func NewJSONReplyDecoder(data []byte) *JSONReplyDecoder

NewJSONReplyDecoder creates a new JSONReplyDecoder for the given frame.

func (*JSONReplyDecoder) Decode

func (d *JSONReplyDecoder) Decode() (*Reply, error)

Decode returns the next Reply in the frame, or io.EOF if there are no replies left. Once Decode fails, it keeps returning the same error until Reset.

func (*JSONReplyDecoder) Reset

func (d *JSONReplyDecoder) Reset(data []byte) error

Reset makes the decoder ready to decode replies from the given frame.

type JSONReplyEncoder

type JSONReplyEncoder struct{}

JSONReplyEncoder is a ReplyEncoder which encodes to JSON.

func NewJSONReplyEncoder

func NewJSONReplyEncoder() *JSONReplyEncoder

NewJSONReplyEncoder creates a new JSONReplyEncoder. It's safe to use the returned encoder concurrently, see also DefaultJsonReplyEncoder.

func (*JSONReplyEncoder) Encode

func (e *JSONReplyEncoder) Encode(r *Reply) ([]byte, error)

Encode Reply to bytes.

type JSONResultEncoder

type JSONResultEncoder struct{}

JSONResultEncoder is a ResultEncoder which encodes to JSON.

func NewJSONResultEncoder

func NewJSONResultEncoder() *JSONResultEncoder

NewJSONResultEncoder creates a new JSONResultEncoder. It's safe to use the returned encoder concurrently.

func (*JSONResultEncoder) EncodeConnectResult

func (e *JSONResultEncoder) EncodeConnectResult(res *ConnectResult) ([]byte, error)

EncodeConnectResult encodes ConnectResult to bytes.

func (*JSONResultEncoder) EncodeHistoryResult

func (e *JSONResultEncoder) EncodeHistoryResult(res *HistoryResult) ([]byte, error)

EncodeHistoryResult encodes HistoryResult to bytes.

func (*JSONResultEncoder) EncodePingResult

func (e *JSONResultEncoder) EncodePingResult(res *PingResult) ([]byte, error)

EncodePingResult encodes PingResult to bytes.

func (*JSONResultEncoder) EncodePresenceResult

func (e *JSONResultEncoder) EncodePresenceResult(res *PresenceResult) ([]byte, error)

EncodePresenceResult encodes PresenceResult to bytes.

func (*JSONResultEncoder) EncodePresenceStatsResult

func (e *JSONResultEncoder) EncodePresenceStatsResult(res *PresenceStatsResult) ([]byte, error)

EncodePresenceStatsResult encodes PresenceStatsResult to bytes.

func (*JSONResultEncoder) EncodePublishResult

func (e *JSONResultEncoder) EncodePublishResult(res *PublishResult) ([]byte, error)

EncodePublishResult encodes PublishResult to bytes.

func (*JSONResultEncoder) EncodeRPCResult

func (e *JSONResultEncoder) EncodeRPCResult(res *RPCResult) ([]byte, error)

EncodeRPCResult encodes RPCResult to bytes.

func (*JSONResultEncoder) EncodeRefreshResult

func (e *JSONResultEncoder) EncodeRefreshResult(res *RefreshResult) ([]byte, error)

EncodeRefreshResult encodes RefreshResult to bytes.

func (*JSONResultEncoder) EncodeSubRefreshResult

func (e *JSONResultEncoder) EncodeSubRefreshResult(res *SubRefreshResult) ([]byte, error)

EncodeSubRefreshResult encodes SubRefreshResult to bytes.

func (*JSONResultEncoder) EncodeSubscribeResult

func (e *JSONResultEncoder) EncodeSubscribeResult(res *SubscribeResult) ([]byte, error)

EncodeSubscribeResult encodes SubscribeResult to bytes.

func (*JSONResultEncoder) EncodeUnsubscribeResult

func (e *JSONResultEncoder) EncodeUnsubscribeResult(res *UnsubscribeResult) ([]byte, error)

EncodeUnsubscribeResult encodes UnsubscribeResult to bytes.

type JSONStreamCommandDecoder added in v0.8.10

type JSONStreamCommandDecoder struct {
	// contains filtered or unexported fields
}

JSONStreamCommandDecoder is a StreamCommandDecoder which reads commands separated by a `\n` delimiter.

func NewJSONStreamCommandDecoder added in v0.8.10

func NewJSONStreamCommandDecoder(reader io.Reader, messageSizeLimit int64) *JSONStreamCommandDecoder

NewJSONStreamCommandDecoder creates a new JSONStreamCommandDecoder reading from reader. messageSizeLimit must be positive; a zero or negative value panics.

func (*JSONStreamCommandDecoder) Decode added in v0.8.10

func (d *JSONStreamCommandDecoder) Decode() (*Command, int, error)

Decode returns the next Command from the stream, see the StreamCommandDecoder interface.

func (*JSONStreamCommandDecoder) Reset added in v0.9.0

func (d *JSONStreamCommandDecoder) Reset(reader io.Reader, messageSizeLimit int64)

Reset makes the decoder read from the given reader, applying the given message size limit.

type Join

type Join struct {

	// Information about the client which subscribed.
	Info *ClientInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"`
	// contains filtered or unexported fields
}

Join is sent when a client subscribes to a channel.

func (*Join) AppendJSON added in v0.23.0

func (m *Join) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Join) DecodeJSON added in v0.23.0

func (m *Join) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Join) Descriptor deprecated

func (*Join) Descriptor() ([]byte, []int)

Deprecated: Use Join.ProtoReflect.Descriptor instead.

func (*Join) GetInfo

func (x *Join) GetInfo() *ClientInfo

func (*Join) MarshalCF added in v0.23.0

func (m *Join) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Join) MarshalToCF added in v0.23.0

func (m *Join) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Join) MarshalToSizedBufferCF added in v0.23.0

func (m *Join) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Join) ProtoMessage

func (*Join) ProtoMessage()

func (*Join) ProtoReflect added in v0.7.0

func (x *Join) ProtoReflect() protoreflect.Message

func (*Join) Reset

func (x *Join) Reset()

func (*Join) SizeCF added in v0.23.0

func (m *Join) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Join) String

func (x *Join) String() string

func (*Join) UnmarshalCF added in v0.23.0

func (m *Join) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type KeyedItem added in v0.19.0

type KeyedItem struct {

	// Item key.
	Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// Version of the item data the client currently holds, zero when it has
	// none. The server only sends data with a greater version.
	Version uint64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
	// contains filtered or unexported fields
}

KeyedItem is a key the client tracks in a shared poll subscription.

func (*KeyedItem) AppendJSON added in v0.23.0

func (m *KeyedItem) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*KeyedItem) DecodeJSON added in v0.23.0

func (m *KeyedItem) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*KeyedItem) Descriptor deprecated added in v0.19.0

func (*KeyedItem) Descriptor() ([]byte, []int)

Deprecated: Use KeyedItem.ProtoReflect.Descriptor instead.

func (*KeyedItem) GetKey added in v0.19.0

func (x *KeyedItem) GetKey() string

func (*KeyedItem) GetVersion added in v0.19.0

func (x *KeyedItem) GetVersion() uint64

func (*KeyedItem) MarshalCF added in v0.23.0

func (m *KeyedItem) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*KeyedItem) MarshalToCF added in v0.23.0

func (m *KeyedItem) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*KeyedItem) MarshalToSizedBufferCF added in v0.23.0

func (m *KeyedItem) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*KeyedItem) ProtoMessage added in v0.19.0

func (*KeyedItem) ProtoMessage()

func (*KeyedItem) ProtoReflect added in v0.19.0

func (x *KeyedItem) ProtoReflect() protoreflect.Message

func (*KeyedItem) Reset added in v0.19.0

func (x *KeyedItem) Reset()

func (*KeyedItem) SizeCF added in v0.23.0

func (m *KeyedItem) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*KeyedItem) String added in v0.19.0

func (x *KeyedItem) String() string

func (*KeyedItem) UnmarshalCF added in v0.23.0

func (m *KeyedItem) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type Leave

type Leave struct {

	// Information about the client which unsubscribed.
	Info *ClientInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"`
	// contains filtered or unexported fields
}

Leave is sent when a client unsubscribes from a channel.

func (*Leave) AppendJSON added in v0.23.0

func (m *Leave) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Leave) DecodeJSON added in v0.23.0

func (m *Leave) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Leave) Descriptor deprecated

func (*Leave) Descriptor() ([]byte, []int)

Deprecated: Use Leave.ProtoReflect.Descriptor instead.

func (*Leave) GetInfo

func (x *Leave) GetInfo() *ClientInfo

func (*Leave) MarshalCF added in v0.23.0

func (m *Leave) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Leave) MarshalToCF added in v0.23.0

func (m *Leave) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Leave) MarshalToSizedBufferCF added in v0.23.0

func (m *Leave) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Leave) ProtoMessage

func (*Leave) ProtoMessage()

func (*Leave) ProtoReflect added in v0.7.0

func (x *Leave) ProtoReflect() protoreflect.Message

func (*Leave) Reset

func (x *Leave) Reset()

func (*Leave) SizeCF added in v0.23.0

func (m *Leave) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Leave) String

func (x *Leave) String() string

func (*Leave) UnmarshalCF added in v0.23.0

func (m *Leave) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type Message

type Message struct {

	// Message payload.
	Data Raw `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

Message is an asynchronous message sent from the server to the client. It is not related to any channel and the client does not reply to it.

func (*Message) AppendJSON added in v0.23.0

func (m *Message) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Message) DecodeJSON added in v0.23.0

func (m *Message) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Message) Descriptor deprecated

func (*Message) Descriptor() ([]byte, []int)

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetData added in v0.7.0

func (x *Message) GetData() []byte

func (*Message) MarshalCF added in v0.23.0

func (m *Message) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Message) MarshalToCF added in v0.23.0

func (m *Message) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Message) MarshalToSizedBufferCF added in v0.23.0

func (m *Message) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect added in v0.7.0

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Reset

func (x *Message) Reset()

func (*Message) SizeCF added in v0.23.0

func (m *Message) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Message) String

func (x *Message) String() string

func (*Message) UnmarshalCF added in v0.23.0

func (m *Message) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type PingRequest

type PingRequest struct {
	// contains filtered or unexported fields
}

PingRequest is not supported by the server at the moment: a command carrying it is rejected. Connection liveness is checked with server pings (empty Reply) and client pongs (empty Command), see ConnectResult.pong.

func (*PingRequest) AppendJSON added in v0.23.0

func (m *PingRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*PingRequest) DecodeJSON added in v0.23.0

func (m *PingRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*PingRequest) Descriptor deprecated

func (*PingRequest) Descriptor() ([]byte, []int)

Deprecated: Use PingRequest.ProtoReflect.Descriptor instead.

func (*PingRequest) MarshalCF added in v0.23.0

func (m *PingRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*PingRequest) MarshalToCF added in v0.23.0

func (m *PingRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PingRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *PingRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PingRequest) ProtoMessage

func (*PingRequest) ProtoMessage()

func (*PingRequest) ProtoReflect added in v0.7.0

func (x *PingRequest) ProtoReflect() protoreflect.Message

func (*PingRequest) Reset

func (x *PingRequest) Reset()

func (*PingRequest) SizeCF added in v0.23.0

func (m *PingRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*PingRequest) String

func (x *PingRequest) String() string

func (*PingRequest) UnmarshalCF added in v0.23.0

func (m *PingRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type PingResult

type PingResult struct {
	// contains filtered or unexported fields
}

PingResult is reserved for a response to PingRequest.

func (*PingResult) AppendJSON added in v0.23.0

func (m *PingResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*PingResult) DecodeJSON added in v0.23.0

func (m *PingResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*PingResult) Descriptor deprecated

func (*PingResult) Descriptor() ([]byte, []int)

Deprecated: Use PingResult.ProtoReflect.Descriptor instead.

func (*PingResult) MarshalCF added in v0.23.0

func (m *PingResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*PingResult) MarshalToCF added in v0.23.0

func (m *PingResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PingResult) MarshalToSizedBufferCF added in v0.23.0

func (m *PingResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PingResult) ProtoMessage

func (*PingResult) ProtoMessage()

func (*PingResult) ProtoReflect added in v0.7.0

func (x *PingResult) ProtoReflect() protoreflect.Message

func (*PingResult) Reset

func (x *PingResult) Reset()

func (*PingResult) SizeCF added in v0.23.0

func (m *PingResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*PingResult) String

func (x *PingResult) String() string

func (*PingResult) UnmarshalCF added in v0.23.0

func (m *PingResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type PresenceRequest

type PresenceRequest struct {

	// Channel to get presence of, required.
	Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
	// contains filtered or unexported fields
}

PresenceRequest asks for the presence information of a channel.

func (*PresenceRequest) AppendJSON added in v0.23.0

func (m *PresenceRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*PresenceRequest) DecodeJSON added in v0.23.0

func (m *PresenceRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*PresenceRequest) Descriptor deprecated

func (*PresenceRequest) Descriptor() ([]byte, []int)

Deprecated: Use PresenceRequest.ProtoReflect.Descriptor instead.

func (*PresenceRequest) GetChannel

func (x *PresenceRequest) GetChannel() string

func (*PresenceRequest) MarshalCF added in v0.23.0

func (m *PresenceRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*PresenceRequest) MarshalToCF added in v0.23.0

func (m *PresenceRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PresenceRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *PresenceRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PresenceRequest) ProtoMessage

func (*PresenceRequest) ProtoMessage()

func (*PresenceRequest) ProtoReflect added in v0.7.0

func (x *PresenceRequest) ProtoReflect() protoreflect.Message

func (*PresenceRequest) Reset

func (x *PresenceRequest) Reset()

func (*PresenceRequest) SizeCF added in v0.23.0

func (m *PresenceRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*PresenceRequest) String

func (x *PresenceRequest) String() string

func (*PresenceRequest) UnmarshalCF added in v0.23.0

func (m *PresenceRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type PresenceResult

type PresenceResult struct {

	// Clients present in the channel, keyed by client id.
	Presence map[string]*ClientInfo `` /* 133-byte string literal not displayed */
	// contains filtered or unexported fields
}

PresenceResult is the result of a presence request.

func (*PresenceResult) AppendJSON added in v0.23.0

func (m *PresenceResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*PresenceResult) DecodeJSON added in v0.23.0

func (m *PresenceResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*PresenceResult) Descriptor deprecated

func (*PresenceResult) Descriptor() ([]byte, []int)

Deprecated: Use PresenceResult.ProtoReflect.Descriptor instead.

func (*PresenceResult) GetPresence

func (x *PresenceResult) GetPresence() map[string]*ClientInfo

func (*PresenceResult) MarshalCF added in v0.23.0

func (m *PresenceResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*PresenceResult) MarshalToCF added in v0.23.0

func (m *PresenceResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PresenceResult) MarshalToSizedBufferCF added in v0.23.0

func (m *PresenceResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PresenceResult) ProtoMessage

func (*PresenceResult) ProtoMessage()

func (*PresenceResult) ProtoReflect added in v0.7.0

func (x *PresenceResult) ProtoReflect() protoreflect.Message

func (*PresenceResult) Reset

func (x *PresenceResult) Reset()

func (*PresenceResult) SizeCF added in v0.23.0

func (m *PresenceResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*PresenceResult) String

func (x *PresenceResult) String() string

func (*PresenceResult) UnmarshalCF added in v0.23.0

func (m *PresenceResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type PresenceStatsRequest

type PresenceStatsRequest struct {

	// Channel to get presence stats of, required.
	Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
	// contains filtered or unexported fields
}

PresenceStatsRequest asks for the presence stats of a channel.

func (*PresenceStatsRequest) AppendJSON added in v0.23.0

func (m *PresenceStatsRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*PresenceStatsRequest) DecodeJSON added in v0.23.0

func (m *PresenceStatsRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*PresenceStatsRequest) Descriptor deprecated

func (*PresenceStatsRequest) Descriptor() ([]byte, []int)

Deprecated: Use PresenceStatsRequest.ProtoReflect.Descriptor instead.

func (*PresenceStatsRequest) GetChannel

func (x *PresenceStatsRequest) GetChannel() string

func (*PresenceStatsRequest) MarshalCF added in v0.23.0

func (m *PresenceStatsRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*PresenceStatsRequest) MarshalToCF added in v0.23.0

func (m *PresenceStatsRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PresenceStatsRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *PresenceStatsRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PresenceStatsRequest) ProtoMessage

func (*PresenceStatsRequest) ProtoMessage()

func (*PresenceStatsRequest) ProtoReflect added in v0.7.0

func (x *PresenceStatsRequest) ProtoReflect() protoreflect.Message

func (*PresenceStatsRequest) Reset

func (x *PresenceStatsRequest) Reset()

func (*PresenceStatsRequest) SizeCF added in v0.23.0

func (m *PresenceStatsRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*PresenceStatsRequest) String

func (x *PresenceStatsRequest) String() string

func (*PresenceStatsRequest) UnmarshalCF added in v0.23.0

func (m *PresenceStatsRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type PresenceStatsResult

type PresenceStatsResult struct {

	// Number of clients (connections) in the channel.
	NumClients uint32 `protobuf:"varint,1,opt,name=num_clients,json=numClients,proto3" json:"num_clients"`
	// Number of unique users in the channel.
	NumUsers uint32 `protobuf:"varint,2,opt,name=num_users,json=numUsers,proto3" json:"num_users"`
	// contains filtered or unexported fields
}

PresenceStatsResult is the result of a presence stats request.

func (*PresenceStatsResult) AppendJSON added in v0.23.0

func (m *PresenceStatsResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*PresenceStatsResult) DecodeJSON added in v0.23.0

func (m *PresenceStatsResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*PresenceStatsResult) Descriptor deprecated

func (*PresenceStatsResult) Descriptor() ([]byte, []int)

Deprecated: Use PresenceStatsResult.ProtoReflect.Descriptor instead.

func (*PresenceStatsResult) GetNumClients

func (x *PresenceStatsResult) GetNumClients() uint32

func (*PresenceStatsResult) GetNumUsers

func (x *PresenceStatsResult) GetNumUsers() uint32

func (*PresenceStatsResult) MarshalCF added in v0.23.0

func (m *PresenceStatsResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*PresenceStatsResult) MarshalToCF added in v0.23.0

func (m *PresenceStatsResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PresenceStatsResult) MarshalToSizedBufferCF added in v0.23.0

func (m *PresenceStatsResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PresenceStatsResult) ProtoMessage

func (*PresenceStatsResult) ProtoMessage()

func (*PresenceStatsResult) ProtoReflect added in v0.7.0

func (x *PresenceStatsResult) ProtoReflect() protoreflect.Message

func (*PresenceStatsResult) Reset

func (x *PresenceStatsResult) Reset()

func (*PresenceStatsResult) SizeCF added in v0.23.0

func (m *PresenceStatsResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*PresenceStatsResult) String

func (x *PresenceStatsResult) String() string

func (*PresenceStatsResult) UnmarshalCF added in v0.23.0

func (m *PresenceStatsResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type ProtobufCommandDecoder

type ProtobufCommandDecoder struct {
	// contains filtered or unexported fields
}

ProtobufCommandDecoder is a CommandDecoder for commands prefixed with their length encoded as a varint.

func NewProtobufCommandDecoder

func NewProtobufCommandDecoder(data []byte) *ProtobufCommandDecoder

NewProtobufCommandDecoder creates a new ProtobufCommandDecoder for the given frame.

func (*ProtobufCommandDecoder) Decode

func (d *ProtobufCommandDecoder) Decode() (*Command, error)

Decode returns the next Command in the frame. The last Command is returned together with io.EOF, see the CommandDecoder interface.

func (*ProtobufCommandDecoder) Reset

func (d *ProtobufCommandDecoder) Reset(data []byte) error

Reset makes the decoder ready to decode commands from the given frame.

type ProtobufCommandEncoder

type ProtobufCommandEncoder struct {
}

ProtobufCommandEncoder is a CommandEncoder which encodes to Protobuf.

func NewProtobufCommandEncoder

func NewProtobufCommandEncoder() *ProtobufCommandEncoder

NewProtobufCommandEncoder creates a new ProtobufCommandEncoder. It's safe to use the returned encoder concurrently.

func (*ProtobufCommandEncoder) Encode

func (e *ProtobufCommandEncoder) Encode(cmd *Command) ([]byte, error)

Encode Command to bytes prefixed with the command length encoded as a varint, so that encoded commands may be sent one after another in a single frame.

type ProtobufDataEncoder added in v0.4.0

type ProtobufDataEncoder struct {
	// contains filtered or unexported fields
}

ProtobufDataEncoder is a DataEncoder which prefixes each message with its length encoded as a varint.

func NewProtobufDataEncoder added in v0.4.0

func NewProtobufDataEncoder() *ProtobufDataEncoder

NewProtobufDataEncoder creates a new ProtobufDataEncoder.

func (*ProtobufDataEncoder) Encode added in v0.4.0

func (e *ProtobufDataEncoder) Encode(data []byte) error

Encode appends an already encoded message to the frame, prefixing it with its length encoded as a varint.

func (*ProtobufDataEncoder) Finish added in v0.4.0

func (e *ProtobufDataEncoder) Finish() []byte

Finish returns a copy of the frame built so far.

func (*ProtobufDataEncoder) FinishNoCopy added in v0.18.2

func (e *ProtobufDataEncoder) FinishNoCopy() []byte

FinishNoCopy returns the frame built so far without copying it, see the DataEncoder interface for the lifetime of the returned slice.

func (*ProtobufDataEncoder) Reset added in v0.4.0

func (e *ProtobufDataEncoder) Reset()

Reset prepares the encoder to build a new frame.

type ProtobufPushEncoder

type ProtobufPushEncoder struct {
}

ProtobufPushEncoder is a PushEncoder which encodes to Protobuf.

func NewProtobufPushEncoder

func NewProtobufPushEncoder() *ProtobufPushEncoder

NewProtobufPushEncoder creates a new ProtobufPushEncoder. It's safe to use the returned encoder concurrently, see also DefaultProtobufPushEncoder.

func (*ProtobufPushEncoder) Encode

func (e *ProtobufPushEncoder) Encode(message *Push) ([]byte, error)

Encode Push to bytes.

func (*ProtobufPushEncoder) EncodeConnect added in v0.4.0

func (e *ProtobufPushEncoder) EncodeConnect(message *Connect, reuse ...[]byte) ([]byte, error)

EncodeConnect to bytes.

func (*ProtobufPushEncoder) EncodeDisconnect added in v0.4.0

func (e *ProtobufPushEncoder) EncodeDisconnect(message *Disconnect, reuse ...[]byte) ([]byte, error)

EncodeDisconnect to bytes.

func (*ProtobufPushEncoder) EncodeJoin

func (e *ProtobufPushEncoder) EncodeJoin(message *Join, reuse ...[]byte) ([]byte, error)

EncodeJoin to bytes.

func (*ProtobufPushEncoder) EncodeLeave

func (e *ProtobufPushEncoder) EncodeLeave(message *Leave, reuse ...[]byte) ([]byte, error)

EncodeLeave to bytes.

func (*ProtobufPushEncoder) EncodeMessage

func (e *ProtobufPushEncoder) EncodeMessage(message *Message, reuse ...[]byte) ([]byte, error)

EncodeMessage to bytes.

func (*ProtobufPushEncoder) EncodePublication

func (e *ProtobufPushEncoder) EncodePublication(message *Publication, reuse ...[]byte) ([]byte, error)

EncodePublication to bytes.

func (*ProtobufPushEncoder) EncodeRefresh added in v0.6.0

func (e *ProtobufPushEncoder) EncodeRefresh(message *Refresh, reuse ...[]byte) ([]byte, error)

EncodeRefresh to bytes.

func (*ProtobufPushEncoder) EncodeSubscribe added in v0.4.0

func (e *ProtobufPushEncoder) EncodeSubscribe(message *Subscribe, reuse ...[]byte) ([]byte, error)

EncodeSubscribe to bytes.

func (*ProtobufPushEncoder) EncodeUnsubscribe added in v0.4.0

func (e *ProtobufPushEncoder) EncodeUnsubscribe(message *Unsubscribe, reuse ...[]byte) ([]byte, error)

EncodeUnsubscribe to bytes.

type ProtobufReplyDecoder

type ProtobufReplyDecoder struct {
	// contains filtered or unexported fields
}

ProtobufReplyDecoder is a ReplyDecoder for replies prefixed with their length encoded as a varint.

func NewProtobufReplyDecoder

func NewProtobufReplyDecoder(data []byte) *ProtobufReplyDecoder

NewProtobufReplyDecoder creates a new ProtobufReplyDecoder for the given frame.

func (*ProtobufReplyDecoder) Decode

func (d *ProtobufReplyDecoder) Decode() (*Reply, error)

Decode returns the next Reply in the frame, or io.EOF if there are no replies left. It returns io.ErrShortBuffer if a length prefix does not match the data which follows it.

func (*ProtobufReplyDecoder) Reset

func (d *ProtobufReplyDecoder) Reset(data []byte) error

Reset makes the decoder ready to decode replies from the given frame.

type ProtobufReplyEncoder

type ProtobufReplyEncoder struct{}

ProtobufReplyEncoder is a ReplyEncoder which encodes to Protobuf.

func NewProtobufReplyEncoder

func NewProtobufReplyEncoder() *ProtobufReplyEncoder

NewProtobufReplyEncoder creates a new ProtobufReplyEncoder. It's safe to use the returned encoder concurrently, see also DefaultProtobufReplyEncoder.

func (*ProtobufReplyEncoder) Encode

func (e *ProtobufReplyEncoder) Encode(r *Reply) ([]byte, error)

Encode Reply to bytes.

type ProtobufResultEncoder

type ProtobufResultEncoder struct{}

ProtobufResultEncoder is a ResultEncoder which encodes to Protobuf.

func NewProtobufResultEncoder

func NewProtobufResultEncoder() *ProtobufResultEncoder

NewProtobufResultEncoder creates a new ProtobufResultEncoder. It's safe to use the returned encoder concurrently.

func (*ProtobufResultEncoder) EncodeConnectResult

func (e *ProtobufResultEncoder) EncodeConnectResult(res *ConnectResult) ([]byte, error)

EncodeConnectResult encodes ConnectResult to bytes.

func (*ProtobufResultEncoder) EncodeHistoryResult

func (e *ProtobufResultEncoder) EncodeHistoryResult(res *HistoryResult) ([]byte, error)

EncodeHistoryResult encodes HistoryResult to bytes.

func (*ProtobufResultEncoder) EncodePingResult

func (e *ProtobufResultEncoder) EncodePingResult(res *PingResult) ([]byte, error)

EncodePingResult encodes PingResult to bytes.

func (*ProtobufResultEncoder) EncodePresenceResult

func (e *ProtobufResultEncoder) EncodePresenceResult(res *PresenceResult) ([]byte, error)

EncodePresenceResult encodes PresenceResult to bytes.

func (*ProtobufResultEncoder) EncodePresenceStatsResult

func (e *ProtobufResultEncoder) EncodePresenceStatsResult(res *PresenceStatsResult) ([]byte, error)

EncodePresenceStatsResult encodes PresenceStatsResult to bytes.

func (*ProtobufResultEncoder) EncodePublishResult

func (e *ProtobufResultEncoder) EncodePublishResult(res *PublishResult) ([]byte, error)

EncodePublishResult encodes PublishResult to bytes.

func (*ProtobufResultEncoder) EncodeRPCResult

func (e *ProtobufResultEncoder) EncodeRPCResult(res *RPCResult) ([]byte, error)

EncodeRPCResult encodes RPCResult to bytes.

func (*ProtobufResultEncoder) EncodeRefreshResult

func (e *ProtobufResultEncoder) EncodeRefreshResult(res *RefreshResult) ([]byte, error)

EncodeRefreshResult encodes RefreshResult to bytes.

func (*ProtobufResultEncoder) EncodeSubRefreshResult

func (e *ProtobufResultEncoder) EncodeSubRefreshResult(res *SubRefreshResult) ([]byte, error)

EncodeSubRefreshResult encodes SubRefreshResult to bytes.

func (*ProtobufResultEncoder) EncodeSubscribeResult

func (e *ProtobufResultEncoder) EncodeSubscribeResult(res *SubscribeResult) ([]byte, error)

EncodeSubscribeResult encodes SubscribeResult to bytes.

func (*ProtobufResultEncoder) EncodeUnsubscribeResult

func (e *ProtobufResultEncoder) EncodeUnsubscribeResult(res *UnsubscribeResult) ([]byte, error)

EncodeUnsubscribeResult encodes UnsubscribeResult to bytes.

type ProtobufStreamCommandDecoder added in v0.8.10

type ProtobufStreamCommandDecoder struct {
	// contains filtered or unexported fields
}

ProtobufStreamCommandDecoder is a StreamCommandDecoder which reads commands prefixed with their length encoded as a varint.

func NewProtobufStreamCommandDecoder added in v0.8.10

func NewProtobufStreamCommandDecoder(reader io.Reader, messageSizeLimit int64) *ProtobufStreamCommandDecoder

NewProtobufStreamCommandDecoder creates a new ProtobufStreamCommandDecoder reading from reader. messageSizeLimit must be positive; a zero or negative value panics, since the varint length prefix is attacker-controlled and used as an allocation size, so an unbounded decoder over untrusted input is a memory-exhaustion hazard.

func (*ProtobufStreamCommandDecoder) Decode added in v0.8.10

func (d *ProtobufStreamCommandDecoder) Decode() (*Command, int, error)

Decode returns the next Command from the stream, see the StreamCommandDecoder interface. The size limit is checked against the length prefix before the command is read, so an oversized command is rejected without buffering it.

func (*ProtobufStreamCommandDecoder) Reset added in v0.9.0

func (d *ProtobufStreamCommandDecoder) Reset(reader io.Reader, messageSizeLimit int64)

Reset makes the decoder read from the given reader, applying the given message size limit.

type Publication

type Publication struct {

	// Publication payload. When Publication.delta is set it is a delta patch
	// against the previous payload. On JSON connections with delta compression
	// negotiated it is a JSON string with the payload (or patch) inside.
	Data Raw `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
	// Optional information about the publisher. Usually it is set only if
	// the publication was sent from the client side.
	Info *ClientInfo `protobuf:"bytes,5,opt,name=info,proto3" json:"info,omitempty"`
	// Position of the publication in the channel stream. Epoch is given in
	// SubscribeResult (and in Publication.epoch when it changes). Zero when the
	// channel has no stream.
	Offset uint64 `protobuf:"varint,6,opt,name=offset,proto3" json:"offset,omitempty"`
	// Optional tags associated with the publication, also used by tags filter,
	// see SubscribeRequest.tf.
	Tags map[string]string `` /* 135-byte string literal not displayed */
	// When set, data is a delta patch against the data of the previous
	// publication in this subscription, see SubscribeRequest.delta.
	Delta bool `protobuf:"varint,8,opt,name=delta,proto3" json:"delta,omitempty"`
	// Time of the publication as Unix timestamp in milliseconds. Used between
	// server nodes, not sent to clients by the current server.
	Time int64 `protobuf:"varint,9,opt,name=time,proto3" json:"time,omitempty"`
	// Channel of the publication. Only set when it differs from the channel of
	// the subscription, i.e. for wildcard subscriptions.
	Channel string `protobuf:"bytes,10,opt,name=channel,proto3" json:"channel,omitempty"`
	// Key of the entry in a map subscription, or of the item in a shared poll
	// subscription. For map presence subscriptions it is a client id or a user
	// id.
	Key string `protobuf:"bytes,11,opt,name=key,proto3" json:"key,omitempty"`
	// When set, the publication removes the entry with the given key from map
	// (or shared poll) state.
	Removed bool `protobuf:"varint,12,opt,name=removed,proto3" json:"removed,omitempty"`
	// Score of the entry used to order ordered map state.
	Score int64 `protobuf:"zigzag64,13,opt,name=score,proto3" json:"score,omitempty"`
	// Optional stream epoch, set to let the client learn the new epoch (for
	// example on the first publication of a new stream).
	Epoch string `protobuf:"bytes,14,opt,name=epoch,proto3" json:"epoch,omitempty"`
	// Previous data used for delta computation during broker fan-out between
	// server nodes. Never sent to clients.
	PrevData Raw `protobuf:"bytes,15,opt,name=prev_data,json=prevData,proto3" json:"prev_data,omitempty"`
	// Version of the item, used by shared poll subscriptions to only deliver
	// data newer than the client already has.
	Version uint64 `protobuf:"varint,16,opt,name=version,proto3" json:"version,omitempty"`
	// contains filtered or unexported fields
}

Publication in a channel.

func (*Publication) AppendJSON added in v0.23.0

func (m *Publication) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Publication) DecodeJSON added in v0.23.0

func (m *Publication) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Publication) Descriptor deprecated

func (*Publication) Descriptor() ([]byte, []int)

Deprecated: Use Publication.ProtoReflect.Descriptor instead.

func (*Publication) GetChannel added in v0.13.4

func (x *Publication) GetChannel() string

func (*Publication) GetData added in v0.7.0

func (x *Publication) GetData() []byte

func (*Publication) GetDelta added in v0.13.0

func (x *Publication) GetDelta() bool

func (*Publication) GetEpoch added in v0.19.0

func (x *Publication) GetEpoch() string

func (*Publication) GetInfo

func (x *Publication) GetInfo() *ClientInfo

func (*Publication) GetKey added in v0.19.0

func (x *Publication) GetKey() string

func (*Publication) GetOffset

func (x *Publication) GetOffset() uint64

func (*Publication) GetPrevData added in v0.19.0

func (x *Publication) GetPrevData() []byte

func (*Publication) GetRemoved added in v0.19.0

func (x *Publication) GetRemoved() bool

func (*Publication) GetScore added in v0.19.0

func (x *Publication) GetScore() int64

func (*Publication) GetTags added in v0.8.1

func (x *Publication) GetTags() map[string]string

func (*Publication) GetTime added in v0.13.3

func (x *Publication) GetTime() int64

func (*Publication) GetVersion added in v0.19.0

func (x *Publication) GetVersion() uint64

func (*Publication) MarshalCF added in v0.23.0

func (m *Publication) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Publication) MarshalToCF added in v0.23.0

func (m *Publication) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Publication) MarshalToSizedBufferCF added in v0.23.0

func (m *Publication) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Publication) ProtoMessage

func (*Publication) ProtoMessage()

func (*Publication) ProtoReflect added in v0.7.0

func (x *Publication) ProtoReflect() protoreflect.Message

func (*Publication) Reset

func (x *Publication) Reset()

func (*Publication) SizeCF added in v0.23.0

func (m *Publication) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Publication) String

func (x *Publication) String() string

func (*Publication) UnmarshalCF added in v0.23.0

func (m *Publication) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type PublishRequest

type PublishRequest struct {

	// Channel to publish to, required.
	Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
	// Publication payload.
	Data Raw `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	// Publish type: 0 - regular publication (default), 1 - map publication.
	Type int32 `protobuf:"varint,3,opt,name=type,proto3" json:"type,omitempty"`
	// Map publication: key of the entry to publish or remove. Passed to the
	// application publish handler, which decides the final key.
	Key string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"`
	// Map publication: when set the entry with the key is removed.
	Removed bool `protobuf:"varint,5,opt,name=removed,proto3" json:"removed,omitempty"`
	// contains filtered or unexported fields
}

PublishRequest publishes data to a channel.

func (*PublishRequest) AppendJSON added in v0.23.0

func (m *PublishRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*PublishRequest) DecodeJSON added in v0.23.0

func (m *PublishRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*PublishRequest) Descriptor deprecated

func (*PublishRequest) Descriptor() ([]byte, []int)

Deprecated: Use PublishRequest.ProtoReflect.Descriptor instead.

func (*PublishRequest) GetChannel

func (x *PublishRequest) GetChannel() string

func (*PublishRequest) GetData added in v0.7.0

func (x *PublishRequest) GetData() []byte

func (*PublishRequest) GetKey added in v0.19.0

func (x *PublishRequest) GetKey() string

func (*PublishRequest) GetRemoved added in v0.19.0

func (x *PublishRequest) GetRemoved() bool

func (*PublishRequest) GetType added in v0.19.0

func (x *PublishRequest) GetType() int32

func (*PublishRequest) MarshalCF added in v0.23.0

func (m *PublishRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*PublishRequest) MarshalToCF added in v0.23.0

func (m *PublishRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PublishRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *PublishRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PublishRequest) ProtoMessage

func (*PublishRequest) ProtoMessage()

func (*PublishRequest) ProtoReflect added in v0.7.0

func (x *PublishRequest) ProtoReflect() protoreflect.Message

func (*PublishRequest) Reset

func (x *PublishRequest) Reset()

func (*PublishRequest) SizeCF added in v0.23.0

func (m *PublishRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*PublishRequest) String

func (x *PublishRequest) String() string

func (*PublishRequest) UnmarshalCF added in v0.23.0

func (m *PublishRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type PublishResult

type PublishResult struct {
	// contains filtered or unexported fields
}

PublishResult is the result of a publish.

func (*PublishResult) AppendJSON added in v0.23.0

func (m *PublishResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*PublishResult) DecodeJSON added in v0.23.0

func (m *PublishResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*PublishResult) Descriptor deprecated

func (*PublishResult) Descriptor() ([]byte, []int)

Deprecated: Use PublishResult.ProtoReflect.Descriptor instead.

func (*PublishResult) MarshalCF added in v0.23.0

func (m *PublishResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*PublishResult) MarshalToCF added in v0.23.0

func (m *PublishResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PublishResult) MarshalToSizedBufferCF added in v0.23.0

func (m *PublishResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*PublishResult) ProtoMessage

func (*PublishResult) ProtoMessage()

func (*PublishResult) ProtoReflect added in v0.7.0

func (x *PublishResult) ProtoReflect() protoreflect.Message

func (*PublishResult) Reset

func (x *PublishResult) Reset()

func (*PublishResult) SizeCF added in v0.23.0

func (m *PublishResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*PublishResult) String

func (x *PublishResult) String() string

func (*PublishResult) UnmarshalCF added in v0.23.0

func (m *PublishResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type Push

type Push struct {

	// Optional numeric channel id, used instead of channel to save bandwidth.
	// Only used in pub, join and leave pushes of subscriptions where the client
	// requested a numeric channel id and the server provided one in
	// SubscribeResult.id. When it is used, channel is empty.
	Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// Channel the push relates to. Empty for pushes not related to a channel
	// (message, connect, disconnect, refresh) and when id is used.
	Channel string `protobuf:"bytes,2,opt,name=channel,proto3" json:"channel,omitempty"`
	// Publication in a subscribed channel.
	Pub *Publication `protobuf:"bytes,4,opt,name=pub,proto3" json:"pub,omitempty"`
	// A client subscribed to the channel, only sent when join/leave pushes are
	// enabled for the subscription.
	Join *Join `protobuf:"bytes,5,opt,name=join,proto3" json:"join,omitempty"`
	// A client unsubscribed from the channel, only sent when join/leave pushes
	// are enabled for the subscription.
	Leave *Leave `protobuf:"bytes,6,opt,name=leave,proto3" json:"leave,omitempty"`
	// Server unsubscribed the client from the channel.
	Unsubscribe *Unsubscribe `protobuf:"bytes,7,opt,name=unsubscribe,proto3" json:"unsubscribe,omitempty"`
	// Asynchronous message from the server to the client, not related to a channel.
	Message *Message `protobuf:"bytes,8,opt,name=message,proto3" json:"message,omitempty"`
	// Server subscribed the client to the channel (server-side subscription).
	Subscribe *Subscribe `protobuf:"bytes,9,opt,name=subscribe,proto3" json:"subscribe,omitempty"`
	// Connection established. Only sent on unidirectional transports, where it
	// is the first push and replaces ConnectResult.
	Connect *Connect `protobuf:"bytes,10,opt,name=connect,proto3" json:"connect,omitempty"`
	// Server is closing the connection. May not be sent on transports which
	// deliver code and reason natively (e.g. in a WebSocket close frame).
	Disconnect *Disconnect `protobuf:"bytes,11,opt,name=disconnect,proto3" json:"disconnect,omitempty"`
	// Connection credentials refreshed on the server side.
	Refresh *Refresh `protobuf:"bytes,12,opt,name=refresh,proto3" json:"refresh,omitempty"`
	// contains filtered or unexported fields
}

Push is an asynchronous message from a server to a client. It is sent inside Reply.push on bidirectional transports, and without additional wrapping on unidirectional transports. An empty Push on a unidirectional transport is a server ping, no response is expected.

func (*Push) AppendJSON added in v0.23.0

func (m *Push) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Push) DecodeJSON added in v0.23.0

func (m *Push) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Push) Descriptor deprecated

func (*Push) Descriptor() ([]byte, []int)

Deprecated: Use Push.ProtoReflect.Descriptor instead.

func (*Push) GetChannel

func (x *Push) GetChannel() string

func (*Push) GetConnect added in v0.8.0

func (x *Push) GetConnect() *Connect

func (*Push) GetDisconnect added in v0.8.0

func (x *Push) GetDisconnect() *Disconnect

func (*Push) GetId added in v0.17.0

func (x *Push) GetId() int64

func (*Push) GetJoin added in v0.8.0

func (x *Push) GetJoin() *Join

func (*Push) GetLeave added in v0.8.0

func (x *Push) GetLeave() *Leave

func (*Push) GetMessage added in v0.8.0

func (x *Push) GetMessage() *Message

func (*Push) GetPub added in v0.8.0

func (x *Push) GetPub() *Publication

func (*Push) GetRefresh added in v0.8.0

func (x *Push) GetRefresh() *Refresh

func (*Push) GetSubscribe added in v0.8.0

func (x *Push) GetSubscribe() *Subscribe

func (*Push) GetUnsubscribe added in v0.8.0

func (x *Push) GetUnsubscribe() *Unsubscribe

func (*Push) MarshalCF added in v0.23.0

func (m *Push) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Push) MarshalToCF added in v0.23.0

func (m *Push) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Push) MarshalToSizedBufferCF added in v0.23.0

func (m *Push) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Push) ProtoMessage

func (*Push) ProtoMessage()

func (*Push) ProtoReflect added in v0.7.0

func (x *Push) ProtoReflect() protoreflect.Message

func (*Push) Reset

func (x *Push) Reset()

func (*Push) SizeCF added in v0.23.0

func (m *Push) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Push) String

func (x *Push) String() string

func (*Push) UnmarshalCF added in v0.23.0

func (m *Push) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type PushEncoder

type PushEncoder interface {
	Encode(*Push) ([]byte, error)
	EncodeMessage(*Message, ...[]byte) ([]byte, error)
	EncodePublication(*Publication, ...[]byte) ([]byte, error)
	EncodeJoin(*Join, ...[]byte) ([]byte, error)
	EncodeLeave(*Leave, ...[]byte) ([]byte, error)
	EncodeUnsubscribe(*Unsubscribe, ...[]byte) ([]byte, error)
	EncodeSubscribe(*Subscribe, ...[]byte) ([]byte, error)
	EncodeConnect(*Connect, ...[]byte) ([]byte, error)
	EncodeDisconnect(*Disconnect, ...[]byte) ([]byte, error)
	EncodeRefresh(*Refresh, ...[]byte) ([]byte, error)
}

PushEncoder encodes Push and its parts to bytes.

Parts of a Push are encoded separately from the Push envelope, so that a payload encoded once may be reused for all subscribers of a channel.

Methods which accept a variadic reuse argument may write the result into the provided buffer if it's large enough, avoiding an allocation. The returned slice may or may not alias the given buffer, so always use the returned value and don't touch the buffer until the result is not needed anymore.

func GetPushEncoder

func GetPushEncoder(protoType Type) PushEncoder

GetPushEncoder returns a PushEncoder for the given protocol type. Any type other than TypeJSON is treated as TypeProtobuf.

type RPCRequest

type RPCRequest struct {

	// Call payload.
	Data Raw `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// Optional method name to route the call.
	Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
	// contains filtered or unexported fields
}

RPCRequest is a remote procedure call handled by the application.

func (*RPCRequest) AppendJSON added in v0.23.0

func (m *RPCRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*RPCRequest) DecodeJSON added in v0.23.0

func (m *RPCRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*RPCRequest) Descriptor deprecated

func (*RPCRequest) Descriptor() ([]byte, []int)

Deprecated: Use RPCRequest.ProtoReflect.Descriptor instead.

func (*RPCRequest) GetData added in v0.7.0

func (x *RPCRequest) GetData() []byte

func (*RPCRequest) GetMethod added in v0.3.3

func (x *RPCRequest) GetMethod() string

func (*RPCRequest) MarshalCF added in v0.23.0

func (m *RPCRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*RPCRequest) MarshalToCF added in v0.23.0

func (m *RPCRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*RPCRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *RPCRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*RPCRequest) ProtoMessage

func (*RPCRequest) ProtoMessage()

func (*RPCRequest) ProtoReflect added in v0.7.0

func (x *RPCRequest) ProtoReflect() protoreflect.Message

func (*RPCRequest) Reset

func (x *RPCRequest) Reset()

func (*RPCRequest) SizeCF added in v0.23.0

func (m *RPCRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*RPCRequest) String

func (x *RPCRequest) String() string

func (*RPCRequest) UnmarshalCF added in v0.23.0

func (m *RPCRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type RPCResult

type RPCResult struct {

	// Result payload.
	Data Raw `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

RPCResult is the result of an RPC call.

func (*RPCResult) AppendJSON added in v0.23.0

func (m *RPCResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*RPCResult) DecodeJSON added in v0.23.0

func (m *RPCResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*RPCResult) Descriptor deprecated

func (*RPCResult) Descriptor() ([]byte, []int)

Deprecated: Use RPCResult.ProtoReflect.Descriptor instead.

func (*RPCResult) GetData added in v0.7.0

func (x *RPCResult) GetData() []byte

func (*RPCResult) MarshalCF added in v0.23.0

func (m *RPCResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*RPCResult) MarshalToCF added in v0.23.0

func (m *RPCResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*RPCResult) MarshalToSizedBufferCF added in v0.23.0

func (m *RPCResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*RPCResult) ProtoMessage

func (*RPCResult) ProtoMessage()

func (*RPCResult) ProtoReflect added in v0.7.0

func (x *RPCResult) ProtoReflect() protoreflect.Message

func (*RPCResult) Reset

func (x *RPCResult) Reset()

func (*RPCResult) SizeCF added in v0.23.0

func (m *RPCResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*RPCResult) String

func (x *RPCResult) String() string

func (*RPCResult) UnmarshalCF added in v0.23.0

func (m *RPCResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type Raw

type Raw []byte

Raw is the type used by the Centrifugal protocol for fields whose value we want to stay untouched – for example the application-specific JSON payload of a published message. It's very similar to json.RawMessage, but its encoding also accounts for the `\n` delimiter used to put several messages into a single transport frame.

Generated code uses Raw instead of []byte for all bytes fields, see generate.sh.

func (Raw) MarshalJSON

func (r Raw) MarshalJSON() ([]byte, error)

MarshalJSON returns r as the JSON encoding of r.

Raw payloads are passed through as is, with one exception: raw newlines are stripped, since a `\n` delimits messages inside a transport frame. Valid JSON only contains raw newlines as formatting whitespace between tokens – newlines within JSON strings are escaped – so removing them doesn't change the payload a subscriber decodes.

The returned slice may alias r, so it must not be modified.

func (*Raw) UnmarshalJSON

func (r *Raw) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *r to a copy of data.

type Refresh added in v0.6.0

type Refresh struct {

	// When set the connection expires, ttl contains time until expiration.
	Expires bool `protobuf:"varint,1,opt,name=expires,proto3" json:"expires,omitempty"`
	// Seconds until the connection expires.
	Ttl uint32 `protobuf:"varint,2,opt,name=ttl,proto3" json:"ttl,omitempty"`
	// contains filtered or unexported fields
}

Refresh is sent when connection credentials were refreshed on the server side.

func (*Refresh) AppendJSON added in v0.23.0

func (m *Refresh) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Refresh) DecodeJSON added in v0.23.0

func (m *Refresh) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Refresh) Descriptor deprecated added in v0.6.0

func (*Refresh) Descriptor() ([]byte, []int)

Deprecated: Use Refresh.ProtoReflect.Descriptor instead.

func (*Refresh) GetExpires added in v0.6.0

func (x *Refresh) GetExpires() bool

func (*Refresh) GetTtl added in v0.6.0

func (x *Refresh) GetTtl() uint32

func (*Refresh) MarshalCF added in v0.23.0

func (m *Refresh) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Refresh) MarshalToCF added in v0.23.0

func (m *Refresh) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Refresh) MarshalToSizedBufferCF added in v0.23.0

func (m *Refresh) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Refresh) ProtoMessage added in v0.6.0

func (*Refresh) ProtoMessage()

func (*Refresh) ProtoReflect added in v0.7.0

func (x *Refresh) ProtoReflect() protoreflect.Message

func (*Refresh) Reset added in v0.6.0

func (x *Refresh) Reset()

func (*Refresh) SizeCF added in v0.23.0

func (m *Refresh) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Refresh) String added in v0.6.0

func (x *Refresh) String() string

func (*Refresh) UnmarshalCF added in v0.23.0

func (m *Refresh) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type RefreshRequest

type RefreshRequest struct {

	// New connection token, required.
	Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
	// contains filtered or unexported fields
}

RefreshRequest refreshes an expiring connection with a new token.

func (*RefreshRequest) AppendJSON added in v0.23.0

func (m *RefreshRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*RefreshRequest) DecodeJSON added in v0.23.0

func (m *RefreshRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*RefreshRequest) Descriptor deprecated

func (*RefreshRequest) Descriptor() ([]byte, []int)

Deprecated: Use RefreshRequest.ProtoReflect.Descriptor instead.

func (*RefreshRequest) GetToken

func (x *RefreshRequest) GetToken() string

func (*RefreshRequest) MarshalCF added in v0.23.0

func (m *RefreshRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*RefreshRequest) MarshalToCF added in v0.23.0

func (m *RefreshRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*RefreshRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *RefreshRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*RefreshRequest) ProtoMessage

func (*RefreshRequest) ProtoMessage()

func (*RefreshRequest) ProtoReflect added in v0.7.0

func (x *RefreshRequest) ProtoReflect() protoreflect.Message

func (*RefreshRequest) Reset

func (x *RefreshRequest) Reset()

func (*RefreshRequest) SizeCF added in v0.23.0

func (m *RefreshRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*RefreshRequest) String

func (x *RefreshRequest) String() string

func (*RefreshRequest) UnmarshalCF added in v0.23.0

func (m *RefreshRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type RefreshResult

type RefreshResult struct {

	// Not set by the current server.
	Client string `protobuf:"bytes,1,opt,name=client,proto3" json:"client,omitempty"`
	// Not set by the current server.
	Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
	// When set the connection still expires, ttl contains time until expiration.
	Expires bool `protobuf:"varint,3,opt,name=expires,proto3" json:"expires,omitempty"`
	// Seconds until the connection expires.
	Ttl uint32 `protobuf:"varint,4,opt,name=ttl,proto3" json:"ttl,omitempty"`
	// contains filtered or unexported fields
}

RefreshResult is the result of a connection refresh.

func (*RefreshResult) AppendJSON added in v0.23.0

func (m *RefreshResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*RefreshResult) DecodeJSON added in v0.23.0

func (m *RefreshResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*RefreshResult) Descriptor deprecated

func (*RefreshResult) Descriptor() ([]byte, []int)

Deprecated: Use RefreshResult.ProtoReflect.Descriptor instead.

func (*RefreshResult) GetClient

func (x *RefreshResult) GetClient() string

func (*RefreshResult) GetExpires

func (x *RefreshResult) GetExpires() bool

func (*RefreshResult) GetTtl added in v0.4.1

func (x *RefreshResult) GetTtl() uint32

func (*RefreshResult) GetVersion

func (x *RefreshResult) GetVersion() string

func (*RefreshResult) MarshalCF added in v0.23.0

func (m *RefreshResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*RefreshResult) MarshalToCF added in v0.23.0

func (m *RefreshResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*RefreshResult) MarshalToSizedBufferCF added in v0.23.0

func (m *RefreshResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*RefreshResult) ProtoMessage

func (*RefreshResult) ProtoMessage()

func (*RefreshResult) ProtoReflect added in v0.7.0

func (x *RefreshResult) ProtoReflect() protoreflect.Message

func (*RefreshResult) Reset

func (x *RefreshResult) Reset()

func (*RefreshResult) SizeCF added in v0.23.0

func (m *RefreshResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*RefreshResult) String

func (x *RefreshResult) String() string

func (*RefreshResult) UnmarshalCF added in v0.23.0

func (m *RefreshResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type Reply

type Reply struct {

	// Id of the Command this Reply responds to. It is zero for pushes.
	Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// Error of the command. Only set in replies to commands, never for pushes.
	// When set, no result field is set.
	Error *Error `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
	// Server sets at most one of the following fields: push for asynchronous
	// pushes, or the result matching the request of the Command. We are not
	// using oneof here due to JSON interoperability concerns.
	Push          *Push                `protobuf:"bytes,4,opt,name=push,proto3" json:"push,omitempty"`
	Connect       *ConnectResult       `protobuf:"bytes,5,opt,name=connect,proto3" json:"connect,omitempty"`
	Subscribe     *SubscribeResult     `protobuf:"bytes,6,opt,name=subscribe,proto3" json:"subscribe,omitempty"`
	Unsubscribe   *UnsubscribeResult   `protobuf:"bytes,7,opt,name=unsubscribe,proto3" json:"unsubscribe,omitempty"`
	Publish       *PublishResult       `protobuf:"bytes,8,opt,name=publish,proto3" json:"publish,omitempty"`
	Presence      *PresenceResult      `protobuf:"bytes,9,opt,name=presence,proto3" json:"presence,omitempty"`
	PresenceStats *PresenceStatsResult `protobuf:"bytes,10,opt,name=presence_stats,json=presenceStats,proto3" json:"presence_stats,omitempty"`
	History       *HistoryResult       `protobuf:"bytes,11,opt,name=history,proto3" json:"history,omitempty"`
	Ping          *PingResult          `protobuf:"bytes,12,opt,name=ping,proto3" json:"ping,omitempty"`
	Rpc           *RPCResult           `protobuf:"bytes,13,opt,name=rpc,proto3" json:"rpc,omitempty"`
	Refresh       *RefreshResult       `protobuf:"bytes,14,opt,name=refresh,proto3" json:"refresh,omitempty"`
	SubRefresh    *SubRefreshResult    `protobuf:"bytes,15,opt,name=sub_refresh,json=subRefresh,proto3" json:"sub_refresh,omitempty"`
	// contains filtered or unexported fields
}

Reply is sent from a server to a client as a response to a Command, or as an asynchronous server-to-client Push.

An empty Reply (all fields unset, i.e. {} in JSON) is a server ping. When ConnectResult.pong is set the client must respond to it with an empty Command.

func (*Reply) AppendJSON added in v0.23.0

func (m *Reply) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Reply) DecodeJSON added in v0.23.0

func (m *Reply) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Reply) Descriptor deprecated

func (*Reply) Descriptor() ([]byte, []int)

Deprecated: Use Reply.ProtoReflect.Descriptor instead.

func (*Reply) GetConnect added in v0.8.0

func (x *Reply) GetConnect() *ConnectResult

func (*Reply) GetError

func (x *Reply) GetError() *Error

func (*Reply) GetHistory added in v0.8.0

func (x *Reply) GetHistory() *HistoryResult

func (*Reply) GetId added in v0.4.1

func (x *Reply) GetId() uint32

func (*Reply) GetPing added in v0.8.0

func (x *Reply) GetPing() *PingResult

func (*Reply) GetPresence added in v0.8.0

func (x *Reply) GetPresence() *PresenceResult

func (*Reply) GetPresenceStats added in v0.8.0

func (x *Reply) GetPresenceStats() *PresenceStatsResult

func (*Reply) GetPublish added in v0.8.0

func (x *Reply) GetPublish() *PublishResult

func (*Reply) GetPush added in v0.8.0

func (x *Reply) GetPush() *Push

func (*Reply) GetRefresh added in v0.8.0

func (x *Reply) GetRefresh() *RefreshResult

func (*Reply) GetRpc added in v0.8.0

func (x *Reply) GetRpc() *RPCResult

func (*Reply) GetSubRefresh added in v0.8.0

func (x *Reply) GetSubRefresh() *SubRefreshResult

func (*Reply) GetSubscribe added in v0.8.0

func (x *Reply) GetSubscribe() *SubscribeResult

func (*Reply) GetUnsubscribe added in v0.8.0

func (x *Reply) GetUnsubscribe() *UnsubscribeResult

func (*Reply) MarshalCF added in v0.23.0

func (m *Reply) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Reply) MarshalToCF added in v0.23.0

func (m *Reply) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Reply) MarshalToSizedBufferCF added in v0.23.0

func (m *Reply) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Reply) ProtoMessage

func (*Reply) ProtoMessage()

func (*Reply) ProtoReflect added in v0.7.0

func (x *Reply) ProtoReflect() protoreflect.Message

func (*Reply) Reset

func (x *Reply) Reset()

func (*Reply) SizeCF added in v0.23.0

func (m *Reply) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Reply) String

func (x *Reply) String() string

func (*Reply) UnmarshalCF added in v0.23.0

func (m *Reply) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type ReplyDecoder

type ReplyDecoder interface {
	// Reset makes the decoder ready to decode replies from the given frame.
	Reset([]byte) error
	// Decode returns the next Reply in the frame, or io.EOF if there are no
	// replies left.
	Decode() (*Reply, error)
}

ReplyDecoder decodes replies from a transport frame which may contain several of them. It's the client-side counterpart of ReplyEncoder.

Unlike CommandDecoder, Decode here returns io.EOF on its own once the frame is fully processed – with a nil Reply.

A ReplyDecoder is not safe for concurrent use.

type ReplyEncoder

type ReplyEncoder interface {
	Encode(*Reply) ([]byte, error)
}

ReplyEncoder encodes Reply to bytes. Use GetReplyEncoder to get an implementation for a concrete protocol Type.

func GetReplyEncoder

func GetReplyEncoder(protoType Type) ReplyEncoder

GetReplyEncoder returns a ReplyEncoder for the given protocol type. Any type other than TypeJSON is treated as TypeProtobuf.

Example

Replies are encoded per protocol type. The encoded result may be sent to a connection as is, or concatenated with other messages using a DataEncoder.

package main

import (
	"fmt"

	"github.com/centrifugal/protocol"
)

func main() {
	reply := &protocol.Reply{
		Id:      1,
		Connect: &protocol.ConnectResult{Client: "6d67dbfd", Version: "6.0.0"},
	}

	data, err := protocol.GetReplyEncoder(protocol.TypeJSON).Encode(reply)
	if err != nil {
		fmt.Println("encode error:", err)
		return
	}
	fmt.Println(string(data))
}
Output:
{"id":1,"connect":{"client":"6d67dbfd","version":"6.0.0"}}

type ReplyPoolCollection added in v0.9.0

type ReplyPoolCollection struct {
	// contains filtered or unexported fields
}

ReplyPoolCollection is a set of pools of Reply objects, one pool per result type. Reusing Reply objects keeps a server from allocating an envelope for every command it answers.

Use the shared ReplyPool rather than creating a collection directly.

func (*ReplyPoolCollection) AcquireConnectReply added in v0.9.0

func (p *ReplyPoolCollection) AcquireConnectReply(result *ConnectResult) *Reply

AcquireConnectReply takes a Reply from the pool and sets the given ConnectResult on it.

func (*ReplyPoolCollection) AcquireHistoryReply added in v0.9.0

func (p *ReplyPoolCollection) AcquireHistoryReply(result *HistoryResult) *Reply

AcquireHistoryReply takes a Reply from the pool and sets the given HistoryResult on it.

func (*ReplyPoolCollection) AcquirePresenceReply added in v0.9.0

func (p *ReplyPoolCollection) AcquirePresenceReply(result *PresenceResult) *Reply

AcquirePresenceReply takes a Reply from the pool and sets the given PresenceResult on it.

func (*ReplyPoolCollection) AcquirePresenceStatsReply added in v0.9.0

func (p *ReplyPoolCollection) AcquirePresenceStatsReply(result *PresenceStatsResult) *Reply

AcquirePresenceStatsReply takes a Reply from the pool and sets the given PresenceStatsResult on it.

func (*ReplyPoolCollection) AcquirePublishReply added in v0.9.0

func (p *ReplyPoolCollection) AcquirePublishReply(result *PublishResult) *Reply

AcquirePublishReply takes a Reply from the pool and sets the given PublishResult on it.

func (*ReplyPoolCollection) AcquireRPCReply added in v0.9.0

func (p *ReplyPoolCollection) AcquireRPCReply(result *RPCResult) *Reply

AcquireRPCReply takes a Reply from the pool and sets the given RPCResult on it.

func (*ReplyPoolCollection) AcquireRefreshReply added in v0.9.0

func (p *ReplyPoolCollection) AcquireRefreshReply(result *RefreshResult) *Reply

AcquireRefreshReply takes a Reply from the pool and sets the given RefreshResult on it.

func (*ReplyPoolCollection) AcquireSubRefreshReply added in v0.9.0

func (p *ReplyPoolCollection) AcquireSubRefreshReply(result *SubRefreshResult) *Reply

AcquireSubRefreshReply takes a Reply from the pool and sets the given SubRefreshResult on it.

func (*ReplyPoolCollection) AcquireSubscribeReply added in v0.9.0

func (p *ReplyPoolCollection) AcquireSubscribeReply(result *SubscribeResult) *Reply

AcquireSubscribeReply takes a Reply from the pool and sets the given SubscribeResult on it.

func (*ReplyPoolCollection) AcquireUnsubscribeReply added in v0.9.0

func (p *ReplyPoolCollection) AcquireUnsubscribeReply(result *UnsubscribeResult) *Reply

AcquireUnsubscribeReply takes a Reply from the pool and sets the given UnsubscribeResult on it.

func (*ReplyPoolCollection) ReleaseConnectReply added in v0.9.0

func (p *ReplyPoolCollection) ReleaseConnectReply(r *Reply)

ReleaseConnectReply clears r and returns it to the pool. Neither r nor the result it referenced must be used after this call.

func (*ReplyPoolCollection) ReleaseHistoryReply added in v0.9.0

func (p *ReplyPoolCollection) ReleaseHistoryReply(r *Reply)

ReleaseHistoryReply clears r and returns it to the pool. Neither r nor the result it referenced must be used after this call.

func (*ReplyPoolCollection) ReleasePresenceReply added in v0.9.0

func (p *ReplyPoolCollection) ReleasePresenceReply(r *Reply)

ReleasePresenceReply clears r and returns it to the pool. Neither r nor the result it referenced must be used after this call.

func (*ReplyPoolCollection) ReleasePresenceStatsReply added in v0.9.0

func (p *ReplyPoolCollection) ReleasePresenceStatsReply(r *Reply)

ReleasePresenceStatsReply clears r and returns it to the pool. Neither r nor the result it referenced must be used after this call.

func (*ReplyPoolCollection) ReleasePublishReply added in v0.9.0

func (p *ReplyPoolCollection) ReleasePublishReply(r *Reply)

ReleasePublishReply clears r and returns it to the pool. Neither r nor the result it referenced must be used after this call.

func (*ReplyPoolCollection) ReleaseRPCReply added in v0.9.0

func (p *ReplyPoolCollection) ReleaseRPCReply(r *Reply)

ReleaseRPCReply clears r and returns it to the pool. Neither r nor the result it referenced must be used after this call.

func (*ReplyPoolCollection) ReleaseRefreshReply added in v0.9.0

func (p *ReplyPoolCollection) ReleaseRefreshReply(r *Reply)

ReleaseRefreshReply clears r and returns it to the pool. Neither r nor the result it referenced must be used after this call.

func (*ReplyPoolCollection) ReleaseSubRefreshReply added in v0.9.0

func (p *ReplyPoolCollection) ReleaseSubRefreshReply(r *Reply)

ReleaseSubRefreshReply clears r and returns it to the pool. Neither r nor the result it referenced must be used after this call.

func (*ReplyPoolCollection) ReleaseSubscribeReply added in v0.9.0

func (p *ReplyPoolCollection) ReleaseSubscribeReply(r *Reply)

ReleaseSubscribeReply clears r and returns it to the pool. Neither r nor the result it referenced must be used after this call.

func (*ReplyPoolCollection) ReleaseUnsubscribeReply added in v0.9.0

func (p *ReplyPoolCollection) ReleaseUnsubscribeReply(r *Reply)

ReleaseUnsubscribeReply clears r and returns it to the pool. Neither r nor the result it referenced must be used after this call.

type ResultEncoder

type ResultEncoder interface {
	EncodeConnectResult(*ConnectResult) ([]byte, error)
	EncodeRefreshResult(*RefreshResult) ([]byte, error)
	EncodeSubscribeResult(*SubscribeResult) ([]byte, error)
	EncodeSubRefreshResult(*SubRefreshResult) ([]byte, error)
	EncodeUnsubscribeResult(*UnsubscribeResult) ([]byte, error)
	EncodePublishResult(*PublishResult) ([]byte, error)
	EncodePresenceResult(*PresenceResult) ([]byte, error)
	EncodePresenceStatsResult(*PresenceStatsResult) ([]byte, error)
	EncodeHistoryResult(*HistoryResult) ([]byte, error)
	EncodePingResult(*PingResult) ([]byte, error)
	EncodeRPCResult(*RPCResult) ([]byte, error)
}

ResultEncoder encodes command results to bytes. Results are encoded separately from the Reply envelope, so that a result may be encoded once and then reused for many connections. Use GetResultEncoder to get an implementation for a concrete protocol Type.

func GetResultEncoder

func GetResultEncoder(protoType Type) ResultEncoder

GetResultEncoder returns a ResultEncoder for the given protocol type. Any type other than TypeJSON is treated as TypeProtobuf.

type SendRequest

type SendRequest struct {

	// Message payload.
	Data Raw `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

SendRequest is an asynchronous message from the client to the server handled by the application. No Reply is sent in response, so the command may have zero id.

func (*SendRequest) AppendJSON added in v0.23.0

func (m *SendRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*SendRequest) DecodeJSON added in v0.23.0

func (m *SendRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*SendRequest) Descriptor deprecated

func (*SendRequest) Descriptor() ([]byte, []int)

Deprecated: Use SendRequest.ProtoReflect.Descriptor instead.

func (*SendRequest) GetData added in v0.7.0

func (x *SendRequest) GetData() []byte

func (*SendRequest) MarshalCF added in v0.23.0

func (m *SendRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*SendRequest) MarshalToCF added in v0.23.0

func (m *SendRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*SendRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *SendRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*SendRequest) ProtoMessage

func (*SendRequest) ProtoMessage()

func (*SendRequest) ProtoReflect added in v0.7.0

func (x *SendRequest) ProtoReflect() protoreflect.Message

func (*SendRequest) Reset

func (x *SendRequest) Reset()

func (*SendRequest) SizeCF added in v0.23.0

func (m *SendRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*SendRequest) String

func (x *SendRequest) String() string

func (*SendRequest) UnmarshalCF added in v0.23.0

func (m *SendRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type StreamCommandDecoder added in v0.8.10

type StreamCommandDecoder interface {
	// Decode returns the next Command from the stream together with the number
	// of bytes attributed to it, or an error. It returns io.EOF when the stream
	// is over and ErrMessageTooLarge if the command exceeds the configured
	// message size limit.
	Decode() (*Command, int, error)
	// Reset makes the decoder read from the given reader, applying the given
	// message size limit. It is used internally to reuse a pooled decoder;
	// obtain a decoder via GetStreamCommandDecoderLimited, which enforces a
	// positive limit, rather than resetting one with a non-positive limit.
	Reset(reader io.Reader, messageSizeLimit int64)
}

StreamCommandDecoder decodes commands from an io.Reader. Unlike CommandDecoder, which works on a frame already read into memory, it's meant for streaming transports where commands arrive one after another and the size of an individual command must be bounded.

A StreamCommandDecoder is not safe for concurrent use. Use GetStreamCommandDecoderLimited and PutStreamCommandDecoder to take one from a pool and return it back when done.

func GetStreamCommandDecoderLimited added in v0.14.0

func GetStreamCommandDecoderLimited(protoType Type, reader io.Reader, messageSizeLimit int64) StreamCommandDecoder

GetStreamCommandDecoderLimited returns a StreamCommandDecoder for the given protocol type, taking it from a pool and resetting it to read commands from reader. Return it with PutStreamCommandDecoder once the stream is processed.

Commands larger than messageSizeLimit bytes are rejected with ErrMessageTooLarge. messageSizeLimit must be positive - a zero or negative limit panics, since an unbounded decoder over untrusted input can be driven to allocate arbitrary memory by a single frame. Any type other than TypeJSON is treated as TypeProtobuf.

type StreamPosition added in v0.6.0

type StreamPosition struct {

	// Stream offset.
	Offset uint64 `protobuf:"varint,1,opt,name=offset,proto3" json:"offset,omitempty"`
	// Stream epoch. Changes when the stream is reset (e.g. history expired or
	// lost), offsets of different epochs are not comparable.
	Epoch string `protobuf:"bytes,2,opt,name=epoch,proto3" json:"epoch,omitempty"`
	// contains filtered or unexported fields
}

StreamPosition is a position in a channel stream.

func (*StreamPosition) AppendJSON added in v0.23.0

func (m *StreamPosition) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*StreamPosition) DecodeJSON added in v0.23.0

func (m *StreamPosition) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*StreamPosition) Descriptor deprecated added in v0.6.0

func (*StreamPosition) Descriptor() ([]byte, []int)

Deprecated: Use StreamPosition.ProtoReflect.Descriptor instead.

func (*StreamPosition) GetEpoch added in v0.6.0

func (x *StreamPosition) GetEpoch() string

func (*StreamPosition) GetOffset added in v0.6.0

func (x *StreamPosition) GetOffset() uint64

func (*StreamPosition) MarshalCF added in v0.23.0

func (m *StreamPosition) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*StreamPosition) MarshalToCF added in v0.23.0

func (m *StreamPosition) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*StreamPosition) MarshalToSizedBufferCF added in v0.23.0

func (m *StreamPosition) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*StreamPosition) ProtoMessage added in v0.6.0

func (*StreamPosition) ProtoMessage()

func (*StreamPosition) ProtoReflect added in v0.7.0

func (x *StreamPosition) ProtoReflect() protoreflect.Message

func (*StreamPosition) Reset added in v0.6.0

func (x *StreamPosition) Reset()

func (*StreamPosition) SizeCF added in v0.23.0

func (m *StreamPosition) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*StreamPosition) String added in v0.6.0

func (x *StreamPosition) String() string

func (*StreamPosition) UnmarshalCF added in v0.23.0

func (m *StreamPosition) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type SubRefreshRequest

type SubRefreshRequest struct {

	// Channel of the subscription, required.
	Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
	// New subscription token, required for type 0.
	Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
	// Request type:
	//
	//	0  refresh subscription token (default).
	//	1  track keys (shared poll), see track.
	//	2  untrack keys (shared poll), see untrack.
	Type int32 `protobuf:"varint,3,opt,name=type,proto3" json:"type,omitempty"`
	// Batches of keys to start tracking, for type 1.
	Track []*TrackBatch `protobuf:"bytes,4,rep,name=track,proto3" json:"track,omitempty"`
	// Keys to stop tracking, for type 2. Also honoured with type 1.
	Untrack []string `protobuf:"bytes,5,rep,name=untrack,proto3" json:"untrack,omitempty"`
	// contains filtered or unexported fields
}

SubRefreshRequest refreshes an expiring subscription with a new token, or manages tracked keys of a shared poll subscription.

func (*SubRefreshRequest) AppendJSON added in v0.23.0

func (m *SubRefreshRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*SubRefreshRequest) DecodeJSON added in v0.23.0

func (m *SubRefreshRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*SubRefreshRequest) Descriptor deprecated

func (*SubRefreshRequest) Descriptor() ([]byte, []int)

Deprecated: Use SubRefreshRequest.ProtoReflect.Descriptor instead.

func (*SubRefreshRequest) GetChannel

func (x *SubRefreshRequest) GetChannel() string

func (*SubRefreshRequest) GetToken

func (x *SubRefreshRequest) GetToken() string

func (*SubRefreshRequest) GetTrack added in v0.19.1

func (x *SubRefreshRequest) GetTrack() []*TrackBatch

func (*SubRefreshRequest) GetType added in v0.19.0

func (x *SubRefreshRequest) GetType() int32

func (*SubRefreshRequest) GetUntrack added in v0.19.1

func (x *SubRefreshRequest) GetUntrack() []string

func (*SubRefreshRequest) MarshalCF added in v0.23.0

func (m *SubRefreshRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*SubRefreshRequest) MarshalToCF added in v0.23.0

func (m *SubRefreshRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*SubRefreshRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *SubRefreshRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*SubRefreshRequest) ProtoMessage

func (*SubRefreshRequest) ProtoMessage()

func (*SubRefreshRequest) ProtoReflect added in v0.7.0

func (x *SubRefreshRequest) ProtoReflect() protoreflect.Message

func (*SubRefreshRequest) Reset

func (x *SubRefreshRequest) Reset()

func (*SubRefreshRequest) SizeCF added in v0.23.0

func (m *SubRefreshRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*SubRefreshRequest) String

func (x *SubRefreshRequest) String() string

func (*SubRefreshRequest) UnmarshalCF added in v0.23.0

func (m *SubRefreshRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type SubRefreshResult

type SubRefreshResult struct {

	// When set the subscription (or tracked keys) expire.
	Expires bool `protobuf:"varint,1,opt,name=expires,proto3" json:"expires,omitempty"`
	// Seconds until expiration. For type 0 - until the subscription token
	// expires. For type 1 - minimal ttl across all tracked batches.
	Ttl uint32 `protobuf:"varint,2,opt,name=ttl,proto3" json:"ttl,omitempty"`
	// Type 1: latest data of tracked keys for which the server has a version
	// newer than the client sent.
	Items []*Publication `protobuf:"bytes,3,rep,name=items,proto3" json:"items,omitempty"`
	// contains filtered or unexported fields
}

SubRefreshResult is the result of SubRefreshRequest.

func (*SubRefreshResult) AppendJSON added in v0.23.0

func (m *SubRefreshResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*SubRefreshResult) DecodeJSON added in v0.23.0

func (m *SubRefreshResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*SubRefreshResult) Descriptor deprecated

func (*SubRefreshResult) Descriptor() ([]byte, []int)

Deprecated: Use SubRefreshResult.ProtoReflect.Descriptor instead.

func (*SubRefreshResult) GetExpires

func (x *SubRefreshResult) GetExpires() bool

func (*SubRefreshResult) GetItems added in v0.19.0

func (x *SubRefreshResult) GetItems() []*Publication

func (*SubRefreshResult) GetTtl added in v0.4.1

func (x *SubRefreshResult) GetTtl() uint32

func (*SubRefreshResult) MarshalCF added in v0.23.0

func (m *SubRefreshResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*SubRefreshResult) MarshalToCF added in v0.23.0

func (m *SubRefreshResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*SubRefreshResult) MarshalToSizedBufferCF added in v0.23.0

func (m *SubRefreshResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*SubRefreshResult) ProtoMessage

func (*SubRefreshResult) ProtoMessage()

func (*SubRefreshResult) ProtoReflect added in v0.7.0

func (x *SubRefreshResult) ProtoReflect() protoreflect.Message

func (*SubRefreshResult) Reset

func (x *SubRefreshResult) Reset()

func (*SubRefreshResult) SizeCF added in v0.23.0

func (m *SubRefreshResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*SubRefreshResult) String

func (x *SubRefreshResult) String() string

func (*SubRefreshResult) UnmarshalCF added in v0.23.0

func (m *SubRefreshResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type Subscribe added in v0.4.0

type Subscribe struct {

	// When set the subscription supports recovery: the client should keep the
	// stream position and pass it in ConnectRequest.subs on reconnect.
	Recoverable bool `protobuf:"varint,1,opt,name=recoverable,proto3" json:"recoverable,omitempty"`
	// Current stream epoch.
	Epoch string `protobuf:"bytes,4,opt,name=epoch,proto3" json:"epoch,omitempty"`
	// Current stream offset.
	Offset uint64 `protobuf:"varint,5,opt,name=offset,proto3" json:"offset,omitempty"`
	// When set the client should track stream position of the subscription.
	Positioned bool `protobuf:"varint,6,opt,name=positioned,proto3" json:"positioned,omitempty"`
	// Optional custom data attached to the subscription by the application.
	Data Raw `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

Subscribe is sent when the server subscribes the client to a channel (server-side subscription) after the connection was established. Server-side subscriptions established at connect time are delivered in ConnectResult.subs instead.

func (*Subscribe) AppendJSON added in v0.23.0

func (m *Subscribe) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Subscribe) DecodeJSON added in v0.23.0

func (m *Subscribe) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Subscribe) Descriptor deprecated added in v0.4.0

func (*Subscribe) Descriptor() ([]byte, []int)

Deprecated: Use Subscribe.ProtoReflect.Descriptor instead.

func (*Subscribe) GetData added in v0.7.0

func (x *Subscribe) GetData() []byte

func (*Subscribe) GetEpoch added in v0.4.0

func (x *Subscribe) GetEpoch() string

func (*Subscribe) GetOffset added in v0.4.0

func (x *Subscribe) GetOffset() uint64

func (*Subscribe) GetPositioned added in v0.4.0

func (x *Subscribe) GetPositioned() bool

func (*Subscribe) GetRecoverable added in v0.4.0

func (x *Subscribe) GetRecoverable() bool

func (*Subscribe) MarshalCF added in v0.23.0

func (m *Subscribe) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Subscribe) MarshalToCF added in v0.23.0

func (m *Subscribe) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Subscribe) MarshalToSizedBufferCF added in v0.23.0

func (m *Subscribe) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Subscribe) ProtoMessage added in v0.4.0

func (*Subscribe) ProtoMessage()

func (*Subscribe) ProtoReflect added in v0.7.0

func (x *Subscribe) ProtoReflect() protoreflect.Message

func (*Subscribe) Reset added in v0.4.0

func (x *Subscribe) Reset()

func (*Subscribe) SizeCF added in v0.23.0

func (m *Subscribe) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Subscribe) String added in v0.4.0

func (x *Subscribe) String() string

func (*Subscribe) UnmarshalCF added in v0.23.0

func (m *Subscribe) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type SubscribeRequest

type SubscribeRequest struct {

	// Channel to subscribe to, required.
	Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
	// Optional subscription token (JWT in Centrifugo).
	Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
	// When set the client asks the server to recover publications missed since
	// the stream position given in epoch and offset.
	Recover bool `protobuf:"varint,3,opt,name=recover,proto3" json:"recover,omitempty"`
	// Stream epoch of the last known position.
	Epoch string `protobuf:"bytes,6,opt,name=epoch,proto3" json:"epoch,omitempty"`
	// Stream offset of the last known position.
	Offset uint64 `protobuf:"varint,7,opt,name=offset,proto3" json:"offset,omitempty"`
	// Optional custom data passed to the application subscribe handler.
	Data Raw `protobuf:"bytes,8,opt,name=data,proto3" json:"data,omitempty"`
	// Hint that the client wants a positioned subscription. The final decision
	// is made by the server, see SubscribeResult.positioned.
	Positioned bool `protobuf:"varint,9,opt,name=positioned,proto3" json:"positioned,omitempty"`
	// Hint that the client wants a recoverable subscription. The final decision
	// is made by the server, see SubscribeResult.recoverable.
	Recoverable bool `protobuf:"varint,10,opt,name=recoverable,proto3" json:"recoverable,omitempty"`
	// Hint that the client wants join/leave pushes. The final decision is made
	// by the server.
	JoinLeave bool `protobuf:"varint,11,opt,name=join_leave,json=joinLeave,proto3" json:"join_leave,omitempty"`
	// Delta compression type the client wants for publications. The only
	// supported value is "fossil". Whether it was negotiated is reported in
	// SubscribeResult.delta.
	Delta string `protobuf:"bytes,12,opt,name=delta,proto3" json:"delta,omitempty"`
	// Optional server-side filter based on publication tags. Only publications
	// matching the filter are delivered. Must be allowed by the server, and
	// disables delta compression. Meant to reduce bandwidth, not as an access
	// control mechanism.
	Tf *FilterNode `protobuf:"bytes,13,opt,name=tf,proto3" json:"tf,omitempty"`
	// Subscription level features, as a bitmask:
	//
	//	1 << 0  numeric channel id requested, see SubscribeResult.id.
	//	1 << 1  reject unrecovered: fail the subscription with error 112
	//	        (unrecoverable position) instead of succeeding with
	//	        SubscribeResult.recovered unset when recovery is not possible.
	Flag int64 `protobuf:"varint,14,opt,name=flag,proto3" json:"flag,omitempty"`
	// Subscription type:
	//
	//	0  stream - regular channel subscription (default).
	//	1  map - subscription to map state with stream of changes.
	//	2  map clients - map of clients present in the channel.
	//	3  map users - map of users present in the channel.
	//	4  shared poll.
	Type int32 `protobuf:"varint,15,opt,name=type,proto3" json:"type,omitempty"`
	// Phase of a map subscription:
	//
	//	0  live - join real-time updates (default).
	//	1  stream - page through stream (catch-up).
	//	2  state - page through map state.
	Phase int32 `protobuf:"varint,16,opt,name=phase,proto3" json:"phase,omitempty"`
	// Map subscriptions: cursor of the state page to load, from
	// SubscribeResult.cursor. Empty for the first page.
	Cursor string `protobuf:"bytes,17,opt,name=cursor,proto3" json:"cursor,omitempty"`
	// Map subscriptions: page size. Zero or negative means server default. The
	// server clamps it to its configured bounds.
	Limit int32 `protobuf:"varint,18,opt,name=limit,proto3" json:"limit,omitempty"`
	// Map subscriptions, state phase: when set ordered map state is returned
	// in ascending order, descending is the default. Ignored for unordered maps.
	Asc bool `protobuf:"varint,19,opt,name=asc,proto3" json:"asc,omitempty"`
	// contains filtered or unexported fields
}

SubscribeRequest subscribes the client to a channel.

Some fields only apply to specific subscription types, see type.

func (*SubscribeRequest) AppendJSON added in v0.23.0

func (m *SubscribeRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*SubscribeRequest) DecodeJSON added in v0.23.0

func (m *SubscribeRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*SubscribeRequest) Descriptor deprecated

func (*SubscribeRequest) Descriptor() ([]byte, []int)

Deprecated: Use SubscribeRequest.ProtoReflect.Descriptor instead.

func (*SubscribeRequest) GetAsc added in v0.19.0

func (x *SubscribeRequest) GetAsc() bool

func (*SubscribeRequest) GetChannel

func (x *SubscribeRequest) GetChannel() string

func (*SubscribeRequest) GetCursor added in v0.19.0

func (x *SubscribeRequest) GetCursor() string

func (*SubscribeRequest) GetData added in v0.7.6

func (x *SubscribeRequest) GetData() []byte

func (*SubscribeRequest) GetDelta added in v0.13.0

func (x *SubscribeRequest) GetDelta() string

func (*SubscribeRequest) GetEpoch

func (x *SubscribeRequest) GetEpoch() string

func (*SubscribeRequest) GetFlag added in v0.17.0

func (x *SubscribeRequest) GetFlag() int64

func (*SubscribeRequest) GetJoinLeave added in v0.8.9

func (x *SubscribeRequest) GetJoinLeave() bool

func (*SubscribeRequest) GetLimit added in v0.19.0

func (x *SubscribeRequest) GetLimit() int32

func (*SubscribeRequest) GetOffset

func (x *SubscribeRequest) GetOffset() uint64

func (*SubscribeRequest) GetPhase added in v0.19.0

func (x *SubscribeRequest) GetPhase() int32

func (*SubscribeRequest) GetPositioned added in v0.8.7

func (x *SubscribeRequest) GetPositioned() bool

func (*SubscribeRequest) GetRecover

func (x *SubscribeRequest) GetRecover() bool

func (*SubscribeRequest) GetRecoverable added in v0.8.7

func (x *SubscribeRequest) GetRecoverable() bool

func (*SubscribeRequest) GetTf added in v0.17.0

func (x *SubscribeRequest) GetTf() *FilterNode

func (*SubscribeRequest) GetToken

func (x *SubscribeRequest) GetToken() string

func (*SubscribeRequest) GetType added in v0.19.0

func (x *SubscribeRequest) GetType() int32

func (*SubscribeRequest) MarshalCF added in v0.23.0

func (m *SubscribeRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*SubscribeRequest) MarshalToCF added in v0.23.0

func (m *SubscribeRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*SubscribeRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *SubscribeRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*SubscribeRequest) ProtoMessage

func (*SubscribeRequest) ProtoMessage()

func (*SubscribeRequest) ProtoReflect added in v0.7.0

func (x *SubscribeRequest) ProtoReflect() protoreflect.Message

func (*SubscribeRequest) Reset

func (x *SubscribeRequest) Reset()

func (*SubscribeRequest) SizeCF added in v0.23.0

func (m *SubscribeRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*SubscribeRequest) String

func (x *SubscribeRequest) String() string

func (*SubscribeRequest) UnmarshalCF added in v0.23.0

func (m *SubscribeRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type SubscribeResult

type SubscribeResult struct {

	// When set the subscription expires and the client must send
	// SubRefreshRequest with a new token before ttl elapses.
	Expires bool `protobuf:"varint,1,opt,name=expires,proto3" json:"expires,omitempty"`
	// Seconds until the subscription expires.
	Ttl uint32 `protobuf:"varint,2,opt,name=ttl,proto3" json:"ttl,omitempty"`
	// When set the subscription supports recovery: the client should keep the
	// stream position and use it on resubscribe.
	Recoverable bool `protobuf:"varint,3,opt,name=recoverable,proto3" json:"recoverable,omitempty"`
	// Current stream epoch.
	Epoch string `protobuf:"bytes,6,opt,name=epoch,proto3" json:"epoch,omitempty"`
	// Publications: recovered after the requested position, initial
	// publications provided by the application, or stream page for maps.
	Publications []*Publication `protobuf:"bytes,7,rep,name=publications,proto3" json:"publications,omitempty"`
	// When set the client successfully recovered all missed publications.
	Recovered bool `protobuf:"varint,8,opt,name=recovered,proto3" json:"recovered,omitempty"`
	// Stream offset. The current stream top, or - when publications were
	// recovered - the position the client advances from by applying them.
	Offset uint64 `protobuf:"varint,9,opt,name=offset,proto3" json:"offset,omitempty"`
	// When set the client should track stream position of the subscription.
	Positioned bool `protobuf:"varint,10,opt,name=positioned,proto3" json:"positioned,omitempty"`
	// Optional custom data attached to the subscription by the application.
	Data Raw `protobuf:"bytes,11,opt,name=data,proto3" json:"data,omitempty"`
	// When set the server attempted recovery for this subscription, check
	// recovered for the outcome.
	WasRecovering bool `protobuf:"varint,12,opt,name=was_recovering,json=wasRecovering,proto3" json:"was_recovering,omitempty"`
	// When set delta compression was negotiated, and Publication.delta tells
	// whether a publication carries a delta patch.
	Delta bool `protobuf:"varint,13,opt,name=delta,proto3" json:"delta,omitempty"`
	// Optional numeric channel id to avoid sending string channel in the
	// following pushes (bandwidth optimization). Set when requested with
	// SubscribeRequest.flag and allowed by the server, see Push.id.
	Id int64 `protobuf:"varint,14,opt,name=id,proto3" json:"id,omitempty"`
	// Type of the subscription: 0 for stream, 1 for all map types (including
	// map clients and map users), 4 for shared poll.
	Type int32 `protobuf:"varint,15,opt,name=type,proto3" json:"type,omitempty"`
	// The result phase of a map subscription (live = 0, stream = 1,
	// state = 2), see SubscribeRequest.phase.
	Phase int32 `protobuf:"varint,16,opt,name=phase,proto3" json:"phase,omitempty"`
	// Map subscriptions, state phase: cursor of the next page. Empty when this
	// is the last state page.
	Cursor string `protobuf:"bytes,17,opt,name=cursor,proto3" json:"cursor,omitempty"`
	// Map subscriptions: state entries.
	State []*Publication `protobuf:"bytes,18,rep,name=state,proto3" json:"state,omitempty"`
	// Interval in milliseconds. When > 0 the SDK should debounce client
	// publications to this channel; the first one is not debounced.
	PublishDebounce uint32 `protobuf:"varint,19,opt,name=publish_debounce,json=publishDebounce,proto3" json:"publish_debounce,omitempty"`
	// contains filtered or unexported fields
}

SubscribeResult is the result of a successful subscribe. It is also used to describe server-side subscriptions in ConnectResult.subs.

func (*SubscribeResult) AppendJSON added in v0.23.0

func (m *SubscribeResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*SubscribeResult) DecodeJSON added in v0.23.0

func (m *SubscribeResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*SubscribeResult) Descriptor deprecated

func (*SubscribeResult) Descriptor() ([]byte, []int)

Deprecated: Use SubscribeResult.ProtoReflect.Descriptor instead.

func (*SubscribeResult) GetCursor added in v0.19.0

func (x *SubscribeResult) GetCursor() string

func (*SubscribeResult) GetData added in v0.7.0

func (x *SubscribeResult) GetData() []byte

func (*SubscribeResult) GetDelta added in v0.13.0

func (x *SubscribeResult) GetDelta() bool

func (*SubscribeResult) GetEpoch

func (x *SubscribeResult) GetEpoch() string

func (*SubscribeResult) GetExpires

func (x *SubscribeResult) GetExpires() bool

func (*SubscribeResult) GetId added in v0.17.0

func (x *SubscribeResult) GetId() int64

func (*SubscribeResult) GetOffset

func (x *SubscribeResult) GetOffset() uint64

func (*SubscribeResult) GetPhase added in v0.19.0

func (x *SubscribeResult) GetPhase() int32

func (*SubscribeResult) GetPositioned added in v0.3.5

func (x *SubscribeResult) GetPositioned() bool

func (*SubscribeResult) GetPublications

func (x *SubscribeResult) GetPublications() []*Publication

func (*SubscribeResult) GetPublishDebounce added in v0.19.0

func (x *SubscribeResult) GetPublishDebounce() uint32

func (*SubscribeResult) GetRecoverable

func (x *SubscribeResult) GetRecoverable() bool

func (*SubscribeResult) GetRecovered

func (x *SubscribeResult) GetRecovered() bool

func (*SubscribeResult) GetState added in v0.19.0

func (x *SubscribeResult) GetState() []*Publication

func (*SubscribeResult) GetTtl added in v0.4.1

func (x *SubscribeResult) GetTtl() uint32

func (*SubscribeResult) GetType added in v0.19.0

func (x *SubscribeResult) GetType() int32

func (*SubscribeResult) GetWasRecovering added in v0.8.5

func (x *SubscribeResult) GetWasRecovering() bool

func (*SubscribeResult) MarshalCF added in v0.23.0

func (m *SubscribeResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*SubscribeResult) MarshalToCF added in v0.23.0

func (m *SubscribeResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*SubscribeResult) MarshalToSizedBufferCF added in v0.23.0

func (m *SubscribeResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*SubscribeResult) ProtoMessage

func (*SubscribeResult) ProtoMessage()

func (*SubscribeResult) ProtoReflect added in v0.7.0

func (x *SubscribeResult) ProtoReflect() protoreflect.Message

func (*SubscribeResult) Reset

func (x *SubscribeResult) Reset()

func (*SubscribeResult) SizeCF added in v0.23.0

func (m *SubscribeResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*SubscribeResult) String

func (x *SubscribeResult) String() string

func (*SubscribeResult) UnmarshalCF added in v0.23.0

func (m *SubscribeResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type TrackBatch added in v0.19.1

type TrackBatch struct {

	// Signature issued by the application backend, an HMAC over (iat, expiry,
	// user, channel, keys).
	Signature string `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"`
	// Full key set the signature was computed over, with versions the client
	// currently holds.
	Items []*KeyedItem `protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"`
	// contains filtered or unexported fields
}

TrackBatch is a set of keys to track authorized by a single signature.

func (*TrackBatch) AppendJSON added in v0.23.0

func (m *TrackBatch) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*TrackBatch) DecodeJSON added in v0.23.0

func (m *TrackBatch) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*TrackBatch) Descriptor deprecated added in v0.19.1

func (*TrackBatch) Descriptor() ([]byte, []int)

Deprecated: Use TrackBatch.ProtoReflect.Descriptor instead.

func (*TrackBatch) GetItems added in v0.19.1

func (x *TrackBatch) GetItems() []*KeyedItem

func (*TrackBatch) GetSignature added in v0.19.1

func (x *TrackBatch) GetSignature() string

func (*TrackBatch) MarshalCF added in v0.23.0

func (m *TrackBatch) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*TrackBatch) MarshalToCF added in v0.23.0

func (m *TrackBatch) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*TrackBatch) MarshalToSizedBufferCF added in v0.23.0

func (m *TrackBatch) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*TrackBatch) ProtoMessage added in v0.19.1

func (*TrackBatch) ProtoMessage()

func (*TrackBatch) ProtoReflect added in v0.19.1

func (x *TrackBatch) ProtoReflect() protoreflect.Message

func (*TrackBatch) Reset added in v0.19.1

func (x *TrackBatch) Reset()

func (*TrackBatch) SizeCF added in v0.23.0

func (m *TrackBatch) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*TrackBatch) String added in v0.19.1

func (x *TrackBatch) String() string

func (*TrackBatch) UnmarshalCF added in v0.23.0

func (m *TrackBatch) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type Type

type Type string

Type determines connection protocol type.

const (
	// TypeJSON means JSON protocol.
	TypeJSON Type = "json"
	// TypeProtobuf means Protobuf protocol.
	TypeProtobuf Type = "protobuf"
)

type Unsubscribe added in v0.4.0

type Unsubscribe struct {

	// Unsubscribe code in range [2000, 2999]. Codes >= 2500 mean the client
	// should resubscribe, codes < 2500 mean it should not. Codes [2000, 2099]
	// and [2500, 2599] are reserved by Centrifuge. Built-in codes:
	//
	//	2000 server unsubscribe
	//	2500 insufficient state
	//	2501 subscription expired
	//	2502 state invalidated - client must drop its subscription token and
	//	     any state accumulated for the subscription before resubscribing
	Code uint32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"`
	// Human readable reason, for logging and debugging.
	Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty"`
	// contains filtered or unexported fields
}

Unsubscribe from a channel, sent by the server.

func (*Unsubscribe) AppendJSON added in v0.23.0

func (m *Unsubscribe) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*Unsubscribe) DecodeJSON added in v0.23.0

func (m *Unsubscribe) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*Unsubscribe) Descriptor deprecated added in v0.4.0

func (*Unsubscribe) Descriptor() ([]byte, []int)

Deprecated: Use Unsubscribe.ProtoReflect.Descriptor instead.

func (*Unsubscribe) GetCode added in v0.8.5

func (x *Unsubscribe) GetCode() uint32

func (*Unsubscribe) GetReason added in v0.8.7

func (x *Unsubscribe) GetReason() string

func (*Unsubscribe) MarshalCF added in v0.23.0

func (m *Unsubscribe) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*Unsubscribe) MarshalToCF added in v0.23.0

func (m *Unsubscribe) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Unsubscribe) MarshalToSizedBufferCF added in v0.23.0

func (m *Unsubscribe) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*Unsubscribe) ProtoMessage added in v0.4.0

func (*Unsubscribe) ProtoMessage()

func (*Unsubscribe) ProtoReflect added in v0.7.0

func (x *Unsubscribe) ProtoReflect() protoreflect.Message

func (*Unsubscribe) Reset added in v0.4.0

func (x *Unsubscribe) Reset()

func (*Unsubscribe) SizeCF added in v0.23.0

func (m *Unsubscribe) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*Unsubscribe) String added in v0.4.0

func (x *Unsubscribe) String() string

func (*Unsubscribe) UnmarshalCF added in v0.23.0

func (m *Unsubscribe) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type UnsubscribeRequest

type UnsubscribeRequest struct {

	// Channel to unsubscribe from.
	Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
	// contains filtered or unexported fields
}

UnsubscribeRequest unsubscribes the client from a channel.

func (*UnsubscribeRequest) AppendJSON added in v0.23.0

func (m *UnsubscribeRequest) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*UnsubscribeRequest) DecodeJSON added in v0.23.0

func (m *UnsubscribeRequest) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*UnsubscribeRequest) Descriptor deprecated

func (*UnsubscribeRequest) Descriptor() ([]byte, []int)

Deprecated: Use UnsubscribeRequest.ProtoReflect.Descriptor instead.

func (*UnsubscribeRequest) GetChannel

func (x *UnsubscribeRequest) GetChannel() string

func (*UnsubscribeRequest) MarshalCF added in v0.23.0

func (m *UnsubscribeRequest) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*UnsubscribeRequest) MarshalToCF added in v0.23.0

func (m *UnsubscribeRequest) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*UnsubscribeRequest) MarshalToSizedBufferCF added in v0.23.0

func (m *UnsubscribeRequest) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*UnsubscribeRequest) ProtoMessage

func (*UnsubscribeRequest) ProtoMessage()

func (*UnsubscribeRequest) ProtoReflect added in v0.7.0

func (x *UnsubscribeRequest) ProtoReflect() protoreflect.Message

func (*UnsubscribeRequest) Reset

func (x *UnsubscribeRequest) Reset()

func (*UnsubscribeRequest) SizeCF added in v0.23.0

func (m *UnsubscribeRequest) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*UnsubscribeRequest) String

func (x *UnsubscribeRequest) String() string

func (*UnsubscribeRequest) UnmarshalCF added in v0.23.0

func (m *UnsubscribeRequest) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

type UnsubscribeResult

type UnsubscribeResult struct {
	// contains filtered or unexported fields
}

UnsubscribeResult is the result of an unsubscribe.

func (*UnsubscribeResult) AppendJSON added in v0.23.0

func (m *UnsubscribeResult) AppendJSON(b []byte) []byte

AppendJSON appends the JSON encoding of m to b.

func (*UnsubscribeResult) DecodeJSON added in v0.23.0

func (m *UnsubscribeResult) DecodeJSON(b []byte, i int, f cfjson.Flags) int

DecodeJSON decodes the JSON value at b[i] into m and returns the index after the value, or a negative number on error, see cfjson.Error.

func (*UnsubscribeResult) Descriptor deprecated

func (*UnsubscribeResult) Descriptor() ([]byte, []int)

Deprecated: Use UnsubscribeResult.ProtoReflect.Descriptor instead.

func (*UnsubscribeResult) MarshalCF added in v0.23.0

func (m *UnsubscribeResult) MarshalCF() ([]byte, error)

MarshalCF returns the Protobuf encoding of m.

func (*UnsubscribeResult) MarshalToCF added in v0.23.0

func (m *UnsubscribeResult) MarshalToCF(b []byte) (int, error)

MarshalToCF writes the Protobuf encoding of m to the beginning of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*UnsubscribeResult) MarshalToSizedBufferCF added in v0.23.0

func (m *UnsubscribeResult) MarshalToSizedBufferCF(b []byte) (int, error)

MarshalToSizedBufferCF writes the Protobuf encoding of m to the end of b, which must have room for SizeCF bytes, and returns the number of bytes written.

func (*UnsubscribeResult) ProtoMessage

func (*UnsubscribeResult) ProtoMessage()

func (*UnsubscribeResult) ProtoReflect added in v0.7.0

func (x *UnsubscribeResult) ProtoReflect() protoreflect.Message

func (*UnsubscribeResult) Reset

func (x *UnsubscribeResult) Reset()

func (*UnsubscribeResult) SizeCF added in v0.23.0

func (m *UnsubscribeResult) SizeCF() (n int)

SizeCF returns the size of the Protobuf encoding of m.

func (*UnsubscribeResult) String

func (x *UnsubscribeResult) String() string

func (*UnsubscribeResult) UnmarshalCF added in v0.23.0

func (m *UnsubscribeResult) UnmarshalCF(b []byte) error

UnmarshalCF decodes the Protobuf encoding of a message from b into m. Fields which are not in b are left as they are. Everything decoded is copied out of b, which may be reused afterwards.

Directories

Path Synopsis
Package cfjson is the runtime for code produced by the cfjson generator (see cmd/cfjson): a small set of append-style encoding helpers and index-based decoding helpers the generated methods are built from.
Package cfjson is the runtime for code produced by the cfjson generator (see cmd/cfjson): a small set of append-style encoding helpers and index-based decoding helpers the generated methods are built from.
cmd/cfjson command
Command cfjson generates JSON encoders and decoders for the structs of a Go package.
Command cfjson generates JSON encoders and decoders for the structs of a Go package.
gen
Package gen generates JSON encoders and decoders for Go structs, built on top of the cfjson runtime package.
Package gen generates JSON encoders and decoders for Go structs, built on top of the cfjson runtime package.
internal/testtypes
Package testtypes has structs covering everything the cfjson generator supports, the tests of the generated code live here too.
Package testtypes has structs covering everything the cfjson generator supports, the tests of the generated code live here too.
internal/testtypes/fold
Package fold has types decoded with the -fold-keys option of the cfjson generator: keys are matched without regard to letter case when they are not the name of a field as written.
Package fold has types decoded with the -fold-keys option of the cfjson generator: keys are matched without regard to letter case when they are not the name of a field as written.
internal/testtypes/foreign
Package foreign has structs which use types of other packages and embed structs, generated for without a change to this file: it stands for a file which is maintained elsewhere.
Package foreign has structs which use types of other packages and embed structs, generated for without a change to this file: it stands for a file which is maintained elsewhere.
internal/testtypes/foreign/ext
Package ext plays the part of a package which is not ours to change: a dependency, or code shared with another project.
Package ext plays the part of a package which is not ours to change: a dependency, or code shared with another project.
Package cfprotobuf is the runtime for code produced by the cfprotobuf generator (see cmd/cfprotobuf): the few primitives of the Protobuf wire format which generated marshalers and unmarshalers are built from.
Package cfprotobuf is the runtime for code produced by the cfprotobuf generator (see cmd/cfprotobuf): the few primitives of the Protobuf wire format which generated marshalers and unmarshalers are built from.
cmd/cfprotobuf command
Command cfprotobuf generates Protobuf marshalers and unmarshalers for the structs protoc-gen-go produces.
Command cfprotobuf generates Protobuf marshalers and unmarshalers for the structs protoc-gen-go produces.
gen
Package gen generates Protobuf marshalers and unmarshalers for the Go structs protoc-gen-go produces, built on top of the cfprotobuf runtime package.
Package gen generates Protobuf marshalers and unmarshalers for the Go structs protoc-gen-go produces, built on top of the cfprotobuf runtime package.
internal/testtypes
Package testtypes has structs covering everything the cfprotobuf generator supports, written the way protoc-gen-go writes them.
Package testtypes has structs covering everything the cfprotobuf generator supports, written the way protoc-gen-go writes them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL