Versions in this module Expand all Collapse all v0 v0.1.0 Sep 28, 2026 Changes in this version + const DefaultBackoffInitial + const DefaultBackoffMax + const DefaultDialTimeout + const DefaultHeartbeat + const DefaultRetention + const DefaultRetentionBytes + const FlagChannel + const FlagCompressed + const FlagEncrypted + const FlagHasMeta + const FlagStream + const MaxMetadataSize + const MaxPayloadSize + const ProtocolVersion + var ErrClosed = errors.New("jsonstream: connection closed") + var ErrMalformed = errors.New("jsonstream: malformed frame") + type Channel struct + func (c *Channel) Cancel() error + func (c *Channel) Close() error + func (c *Channel) Receive(ctx context.Context) (*Message, error) + func (c *Channel) Send(v any) error + type Client struct + func Dial(ctx context.Context, addr string, cfg Config) (*Client, error) + func (c *Client) Channel(ctx context.Context, route string, payload any) (*Channel, error) + func (c *Client) Close() error + func (c *Client) Handle(route string, h func(*Request) (any, error)) + func (c *Client) HandleChannel(route string, h func(*Channel) error) + func (c *Client) HandleOneWay(route string, h func(*Message) error) + func (c *Client) HandleStream(route string, h func(*Request, Emitter) error) + func (c *Client) OnReconnect(fn func()) + func (c *Client) OnResumeFailed(fn func(error)) + func (c *Client) Publish(ctx context.Context, topic string, payload any) error + func (c *Client) Request(ctx context.Context, route string, payload any) (*Message, error) + func (c *Client) SendOneWay(ctx context.Context, route string, payload any) error + func (c *Client) SessionID() string + func (c *Client) Stream(ctx context.Context, route string, payload any) (*ReadStream, error) + func (c *Client) Subscribe(ctx context.Context, topic string, h func(*Message) error) (*Subscription, error) + type Config struct + Auth string + BackoffInitial time.Duration + BackoffMax time.Duration + Compress bool + Credit int + DialTimeout time.Duration + Encrypt bool + Heartbeat time.Duration + Key []byte + Logger Logger + Reconnect *bool + Retention time.Duration + RetentionBytes int + func DefaultConfig() Config + type ConnectJSON struct + Auth string + Compress bool + Credit int + Encrypt bool + HeartbeatMS int + SessionID string + Version int + type Emitter interface + Emit func(v any) error + type Error struct + Code ErrorCode + Message string + func (e *Error) Error() string + func (e *Error) IsProtocol() bool + type ErrorCode uint8 + const CodeAuthDenied + const CodeBusy + const CodeCancelled + const CodeInternal + const CodeInvalid + const CodeNotFound + const CodeProtocol + const CodeSessionExpired + const CodeTimeout + const CodeUnsupported + func (c ErrorCode) String() string + type Frame struct + Metadata []byte + Payload []byte + func ReadFrame(r io.Reader) (*Frame, error) + func (f *Frame) String() string + type FrameType uint8 + const TypeCancel + const TypeComplete + const TypeConnAck + const TypeConnect + const TypeCredit + const TypeError + const TypeOneWay + const TypePing + const TypePong + const TypePublish + const TypeRequest + const TypeResponse + const TypeSubAck + const TypeSubscribe + const TypeUnsubscribe + func (t FrameType) String() string + type Header struct + Flags uint8 + StreamID uint32 + Type FrameType + Version uint8 + type Logger interface + Printf func(format string, v ...any) + type Message struct + Payload json.RawMessage + Route string + StreamID uint32 + Topic string + func (m *Message) Decode(v any) error + type ReadStream struct + func (s *ReadStream) Cancel() error + func (s *ReadStream) Err() error + func (s *ReadStream) Next(ctx context.Context) (*Message, bool) + type Request struct + func (r *Request) Context() context.Context + type Server struct + func NewServer(ln net.Listener, cfg Config) (*Server, error) + func (s *Server) Channel(ctx context.Context, sessionID, route string, payload any) (*Channel, error) + func (s *Server) Close() error + func (s *Server) Handle(route string, h func(*Request) (any, error)) + func (s *Server) HandleChannel(route string, h func(*Channel) error) + func (s *Server) HandleOneWay(route string, h func(*Message) error) + func (s *Server) HandlePublish(topic string, h func(*Message) error) + func (s *Server) HandleStream(route string, h func(*Request, Emitter) error) + func (s *Server) OnAuth(h func(*ConnectJSON) error) + func (s *Server) Publish(ctx context.Context, topic string, payload any) error + func (s *Server) Request(ctx context.Context, sessionID, route string, payload any) (*Message, error) + func (s *Server) SendOneWay(ctx context.Context, sessionID, route string, payload any) error + func (s *Server) Serve() error + func (s *Server) Sessions() []string + func (s *Server) Stream(ctx context.Context, sessionID, route string, payload any) (*ReadStream, error) + type Subscription struct + func (s *Subscription) Close() error