Documentation
¶
Index ¶
- Constants
- type AppendMessageResponse
- type Client
- func (ec *Client) Close() error
- func (ec *Client) CommitOffsets(ctx context.Context) error
- func (ec *Client) Connect(ctx context.Context, startingSubs *[]SubscriptionRequest) error
- func (ec *Client) HandleConnection(ctx context.Context)
- func (ec *Client) IncomingMsgChannel() chan Message
- func (ec *Client) OffsetManager(ctx context.Context)
- func (ec *Client) PollingLoop(ctx context.Context)
- func (ec *Client) Publish(ctx context.Context, topic, content string, ...) (*AppendMessageResponse, error)
- func (ec *Client) RawMsgChannel() chan WebsocketFrame
- func (ec *Client) SetVerbose(verbose bool)
- func (ec *Client) Stop() error
- func (ec *Client) Subscribe(ctx context.Context, subReq SubscriptionRequest) error
- type ECDSASignature
- type EventClient
- type EventClientOpts
- type EventPayload
- type FetchPayload
- type FetchResponseEvent
- type FetchResponsePayload
- type HTTPPublishRequest
- type HTTPPublishResponse
- type MTLSTransport
- type Message
- type OffsetCommitMsg
- type Subscription
- type SubscriptionRequest
- type SubscriptionResponse
- type WFAppendMessageResp
- type WFFetchMessage
- type WFFetchResponse
- type WFMessage
- type WFOffsetCommitMsg
- type WFPingMessage
- type WFPongMessage
- type WFPublishMessage
- type WFSubscriptionReq
- type WFSubscriptionResp
- type WebsocketFrame
Constants ¶
const ( MessageTypePing = "ping" MessageTypePong = "pong" MessageTypeSubscribe = "subscribe" MessageTypeSubscribeResp = "subscribe_response" MessageTypeEvent = "event" MessageTypeEventAck = "event_ack" MessageTypeCommitOffset = "commit_offset" MessageTypeFetch = "fetch" MessageTypeFetchResp = "fetch_response" )
message types
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppendMessageResponse ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewEventClient ¶
func NewEventClient(opts EventClientOpts) (*Client, error)
func (*Client) Connect ¶
func (ec *Client) Connect(ctx context.Context, startingSubs *[]SubscriptionRequest) error
Connect establishes the connection to the event bus and sets up initial subscriptions if provided.
func (*Client) HandleConnection ¶
func (*Client) IncomingMsgChannel ¶
func (*Client) OffsetManager ¶
func (*Client) PollingLoop ¶
PollingLoop continuously sends fetch requests using long polling The server holds each request for up to 5 seconds, providing near-instant message delivery when available while minimizing network overhead
func (*Client) RawMsgChannel ¶
func (ec *Client) RawMsgChannel() chan WebsocketFrame
func (*Client) SetVerbose ¶
type ECDSASignature ¶ added in v1.2.0
ECDSASignature represents an ECDSA signature in ASN.1 DER format
type EventClient ¶
type EventClient interface {
Connect(ctx context.Context, startingSubs *[]SubscriptionRequest) error
IncomingMsgChannel() chan Message
Publish(
ctx context.Context,
topic, content string,
targetType, targetID, traceID, orgID *string,
) (*AppendMessageResponse, error)
Subscribe(ctx context.Context, subReq SubscriptionRequest) error
}
type EventClientOpts ¶
type EventClientOpts struct {
Endpoint string
AuthToken string // JWT token for authentication (optional if using mTLS)
CommitInterval string
GroupID string
// mTLS Authentication (optional, alternative to AuthToken)
CertPath string // Path to client certificate PEM file
KeyPath string // Path to private key PEM file
}
type EventPayload ¶
type EventPayload struct {
Offset int `json:"offset"`
PartitionID string `json:"partition_id"`
Message Message `json:"message"`
}
EventPayload wraps a message with offset and partition metadata (for consuming)
type FetchResponseEvent ¶
type FetchResponseEvent struct {
SubscriptionID string `json:"subscription_id"`
PartitionID string `json:"partition_id"`
Offset int `json:"offset"`
Message Message `json:"message"`
}
FetchResponseEvent represents a single event in a fetch response
type FetchResponsePayload ¶
type FetchResponsePayload struct {
Count int `json:"count"`
Messages []FetchResponseEvent `json:"messages"`
}
FetchResponsePayload contains the array of events from a fetch request
type HTTPPublishRequest ¶
type HTTPPublishRequest struct {
Topic string `json:"topic"`
Content string `json:"content"`
OrgID string `json:"org_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
TargetType string `json:"target_type,omitempty"`
TargetID string `json:"target_id,omitempty"`
}
HTTP Publishing Types
type HTTPPublishResponse ¶
type MTLSTransport ¶ added in v1.2.0
type MTLSTransport struct {
// contains filtered or unexported fields
}
MTLSTransport wraps http.RoundTripper to add mTLS headers
type Message ¶
type Message struct {
ID string `bson:"_id,omitempty" json:"id"`
Topic string `bson:"topic" json:"topic"`
Content string `bson:"content" json:"content"`
Offset int `bson:"offset,omitempty" json:"offset,omitempty"`
PartitionID string `bson:"partition_id,omitempty" json:"partition_id,omitempty"`
TargetType *string `bson:"target_type" json:"target_type"`
TargetID *string `bson:"target_id" json:"target_id"`
TraceID *string `bson:"trace_id,omitempty" json:"trace_id,omitempty"`
OrgID *string `bson:"org_id,omitempty" json:"org_id,omitempty"`
}
the main message structure used in the event bus
type OffsetCommitMsg ¶
type Subscription ¶
type Subscription struct {
SubscriptionRequest `json:",inline"`
ID string `json:"id"`
}
type SubscriptionRequest ¶
type SubscriptionResponse ¶
type WFAppendMessageResp ¶
type WFAppendMessageResp struct {
WebsocketFrame `json:",inline"`
Payload AppendMessageResponse `json:"payload"`
}
type WFFetchMessage ¶
type WFFetchMessage struct {
WebsocketFrame `json:",inline"`
Payload FetchPayload `json:"payload"`
}
WFFetchMessage represents a fetch request to pull new messages
type WFFetchResponse ¶
type WFFetchResponse struct {
WebsocketFrame `json:",inline"`
Payload FetchResponsePayload `json:"payload"`
}
WFFetchResponse represents a fetch response with messages
type WFMessage ¶
type WFMessage struct {
WebsocketFrame `json:",inline"`
Payload EventPayload `json:"payload"`
}
WFMessage for consuming events (with offset and partition wrapper)
type WFOffsetCommitMsg ¶
type WFOffsetCommitMsg struct {
WebsocketFrame `json:",inline"`
Payload OffsetCommitMsg `json:"payload"`
}
type WFPingMessage ¶
type WFPingMessage struct {
WebsocketFrame `json:",inline"`
}
func NewPingPongMessage ¶
func NewPingPongMessage(msgTyp string) WFPingMessage
type WFPongMessage ¶
type WFPongMessage struct {
WebsocketFrame `json:",inline"`
}
type WFPublishMessage ¶
type WFPublishMessage struct {
WebsocketFrame `json:",inline"`
Payload Message `json:"payload"`
}
WFPublishMessage for publishing events (direct message fields)
func NewWebsocketFramedMessage ¶
func NewWebsocketFramedMessage(msg Message) WFPublishMessage
type WFSubscriptionReq ¶
type WFSubscriptionReq struct {
WebsocketFrame `json:",inline"`
Payload SubscriptionRequest `json:"payload"`
}
func NewWebsocketFramedSubscriptionReq ¶
func NewWebsocketFramedSubscriptionReq(subReq SubscriptionRequest) WFSubscriptionReq
type WFSubscriptionResp ¶
type WFSubscriptionResp struct {
WebsocketFrame `json:",inline"`
Payload SubscriptionResponse `json:"payload"`
}
type WebsocketFrame ¶
type WebsocketFrame struct {
MessageType string `json:"message_type"`
Version string `json:"version"`
Payload any `json:"payload"`
}
WebSocket Types
func (*WebsocketFrame) ToAppendMessageResp ¶
func (wf *WebsocketFrame) ToAppendMessageResp() WFAppendMessageResp
func (*WebsocketFrame) ToFetchResponse ¶
func (wf *WebsocketFrame) ToFetchResponse() WFFetchResponse
func (*WebsocketFrame) ToMessage ¶
func (wf *WebsocketFrame) ToMessage() WFMessage
func (*WebsocketFrame) ToPing ¶
func (wf *WebsocketFrame) ToPing() WFPingMessage
func (*WebsocketFrame) ToSubscriptionResp ¶
func (wf *WebsocketFrame) ToSubscriptionResp() WFSubscriptionResp