Documentation
¶
Overview ¶
Package client contains the internal implementation behind the public osmose package.
It owns lifecycle, gateway, event, and service wiring while the root package keeps the public API surface in client.go.
Index ¶
- Constants
- Variables
- func IsPermanent(err error) bool
- type ChannelDeleteEvent
- type ChannelDeleteHandler
- type ChannelUpdateEvent
- type ChannelUpdateHandler
- type ChatTypingEvent
- type ChatTypingHandler
- type Client
- func (c *Client) AwaitInteraction(ctx context.Context, options InteractionCollectorOptions) (*InteractionEvent, error)
- func (c *Client) AwaitMessage(ctx context.Context, options MessageCollectorOptions) (*MessageCreateEvent, error)
- func (c *Client) AwaitReaction(ctx context.Context, options ReactionCollectorOptions) (*MessageReactionsEvent, error)
- func (c *Client) Close() error
- func (c *Client) CollectInteractions(options InteractionCollectorOptions) (*InteractionCollector, error)
- func (c *Client) CollectInteractionsContext(ctx context.Context, options InteractionCollectorOptions) (*InteractionCollector, error)
- func (c *Client) CollectMessages(options MessageCollectorOptions) (*MessageCollector, error)
- func (c *Client) CollectMessagesContext(ctx context.Context, options MessageCollectorOptions) (*MessageCollector, error)
- func (c *Client) CollectReactions(options ReactionCollectorOptions) (*ReactionCollector, error)
- func (c *Client) CollectReactionsContext(ctx context.Context, options ReactionCollectorOptions) (*ReactionCollector, error)
- func (c *Client) Done() <-chan struct{}
- func (c *Client) DroppedEvents() uint64
- func (c *Client) OnChannelDelete(handler ChannelDeleteHandler) func()
- func (c *Client) OnChannelUpdate(handler ChannelUpdateHandler) func()
- func (c *Client) OnChatTyping(handler ChatTypingHandler) func()
- func (c *Client) OnCommunityDelete(handler CommunityDeleteHandler) func()
- func (c *Client) OnCommunityUpdate(handler CommunityUpdateHandler) func()
- func (c *Client) OnConnected(handler ConnectionHandler) func()
- func (c *Client) OnConnecting(handler ConnectionHandler) func()
- func (c *Client) OnConnectionError(handler ConnectionHandler) func()
- func (c *Client) OnConversationLastRead(handler ConversationLastReadHandler) func()
- func (c *Client) OnDisconnected(handler ConnectionHandler) func()
- func (c *Client) OnError(handler ConnectionHandler) func()
- func (c *Client) OnInteraction(handler InteractionHandler) func()
- func (c *Client) OnMemberCreate(handler MemberCreateHandler) func()
- func (c *Client) OnMemberDelete(handler MemberDeleteHandler) func()
- func (c *Client) OnMemberUpdate(handler MemberUpdateHandler) func()
- func (c *Client) OnMessageCreate(handler MessageCreateHandler) func()
- func (c *Client) OnMessageDelete(handler MessageDeleteHandler) func()
- func (c *Client) OnMessageReactions(handler MessageReactionsHandler) func()
- func (c *Client) OnMessageUpdate(handler MessageUpdateHandler) func()
- func (c *Client) OnReady(handler ReadyHandler) func()
- func (c *Client) OnReconnecting(handler ConnectionHandler) func()
- func (c *Client) OnUpdate(handler UpdateHandler) func()
- func (c *Client) OnUserUpdate(handler UserUpdateHandler) func()
- func (c *Client) OnVoiceRoomParticipant(handler VoiceRoomParticipantHandler) func()
- func (c *Client) OnVoiceRoomState(handler VoiceRoomStateHandler) func()
- func (c *Client) Raw() *RawClient
- func (c *Client) Run(ctx context.Context) error
- func (c *Client) SessionID() types.ID
- func (c *Client) Shutdown(ctx context.Context) error
- func (c *Client) State() State
- func (c *Client) User() *types.User
- func (c *Client) WaitReady(ctx context.Context) error
- type CollectorError
- type CollectorResult
- type CommunityDeleteEvent
- type CommunityDeleteHandler
- type CommunityUpdateEvent
- type CommunityUpdateHandler
- type Config
- type ConnectionEvent
- type ConnectionHandler
- type ConversationLastReadEvent
- type ConversationLastReadHandler
- type EndReason
- type EventOverflowHandler
- type HandlerError
- type HandlerErrorHandler
- type InteractionCollector
- type InteractionCollectorOptions
- type InteractionEvent
- type InteractionHandler
- type MemberCreateEvent
- type MemberCreateHandler
- type MemberDeleteEvent
- type MemberDeleteHandler
- type MemberUpdateEvent
- type MemberUpdateHandler
- type MessageCollector
- type MessageCollectorOptions
- type MessageCreateEvent
- type MessageCreateHandler
- type MessageDeleteEvent
- type MessageDeleteHandler
- type MessageReactionsEvent
- type MessageReactionsHandler
- type MessageUpdateEvent
- type MessageUpdateHandler
- type PermanentError
- type RPCError
- type RawClient
- type ReactionCollector
- type ReactionCollectorOptions
- type ReadyEvent
- type ReadyHandler
- type State
- type UnexpectedResultError
- type UpdateEvent
- type UpdateHandler
- type UserUpdateEvent
- type UserUpdateHandler
- type VoiceRoomParticipantEvent
- type VoiceRoomParticipantHandler
- type VoiceRoomStateEvent
- type VoiceRoomStateHandler
Constants ¶
const ( EndReasonTime = collectors.EndReasonTime EndReasonIdle = collectors.EndReasonIdle EndReasonLimit = collectors.EndReasonLimit EndReasonStopped = collectors.EndReasonStopped EndReasonContext = collectors.EndReasonContext EndReasonOverflow = collectors.EndReasonOverflow EndReasonClosed = collectors.EndReasonClosed )
const ( Disconnected = events.Disconnected Connecting = events.Connecting Initializing = events.Initializing Authenticating = events.Authenticating Ready = events.Ready Closing = events.Closing )
Variables ¶
var ( ErrCollectorEnded = collectors.ErrCollectorEnded ErrCollectorTimeout = collectors.ErrCollectorTimeout ErrCollectorIdle = collectors.ErrCollectorIdle ErrCollectorOverflow = collectors.ErrCollectorOverflow ErrCollectorClosed = collectors.ErrCollectorClosed )
var ( ErrClosed = events.ErrClosed ErrNotConnected = errors.New("osmose client is not connected") ErrNotReady = errors.New("osmose client is not ready") ErrAlreadyRunning = errors.New("osmose client is already running") ErrRunCompleted = errors.New("osmose client run has completed") ErrPermanent = errors.New("osmose permanent error") ErrAuthorizationFailed = errors.New("osmose authorization failed") ErrProtocolMismatch = errors.New("osmose protocol mismatch") ErrDisconnected = rpc.ErrDisconnected ErrUnsupportedRequest = rpc.ErrUnsupportedRequest )
var ErrEventQueueFull = eventtypes.ErrEventQueueFull
Functions ¶
func IsPermanent ¶
IsPermanent reports whether err contains a permanent Osmose error.
Types ¶
type ChannelDeleteEvent ¶
type ChannelDeleteEvent = eventtypes.ChannelDeleteEvent
type ChannelDeleteHandler ¶
type ChannelDeleteHandler = eventtypes.ChannelDeleteHandler
type ChannelUpdateEvent ¶
type ChannelUpdateEvent = eventtypes.ChannelUpdateEvent
type ChannelUpdateHandler ¶
type ChannelUpdateHandler = eventtypes.ChannelUpdateHandler
type ChatTypingEvent ¶
type ChatTypingEvent = eventtypes.ChatTypingEvent
type ChatTypingHandler ¶
type ChatTypingHandler = eventtypes.ChatTypingHandler
type Client ¶
type Client struct {
Messages *messages.Service
Chats *chats.Service
Communities *communities.Service
Users *users.Service
Reactions *reactions.Service
Voice *voice.Service
// contains filtered or unexported fields
}
Client is the central Osmose client. Services are initialized and ready to use immediately; network operations wait until Run has completed auth. A client has one lifecycle: reconnects happen inside Run, and a completed Run cannot be started again.
func (*Client) AwaitInteraction ¶
func (c *Client) AwaitInteraction(ctx context.Context, options InteractionCollectorOptions) (*InteractionEvent, error)
AwaitInteraction waits for the first interaction matching options.
func (*Client) AwaitMessage ¶
func (c *Client) AwaitMessage(ctx context.Context, options MessageCollectorOptions) (*MessageCreateEvent, error)
AwaitMessage waits for the first message matching options. Its Max value is always one; use CollectMessages when multiple messages are needed.
func (*Client) AwaitReaction ¶
func (c *Client) AwaitReaction(ctx context.Context, options ReactionCollectorOptions) (*MessageReactionsEvent, error)
AwaitReaction waits for the first matching reaction snapshot.
func (*Client) Close ¶
Close stops the run loop and active connection. Run returns after its current handler and connection cleanup finish.
func (*Client) CollectInteractions ¶
func (c *Client) CollectInteractions(options InteractionCollectorOptions) (*InteractionCollector, error)
CollectInteractions starts a bounded interaction collector.
func (*Client) CollectInteractionsContext ¶
func (c *Client) CollectInteractionsContext(ctx context.Context, options InteractionCollectorOptions) (*InteractionCollector, error)
CollectInteractionsContext starts an interaction collector tied to ctx and the client lifecycle.
func (*Client) CollectMessages ¶
func (c *Client) CollectMessages(options MessageCollectorOptions) (*MessageCollector, error)
CollectMessages starts a bounded message collector. Use Stop when no Time, Idle, or Max limit is configured.
func (*Client) CollectMessagesContext ¶
func (c *Client) CollectMessagesContext(ctx context.Context, options MessageCollectorOptions) (*MessageCollector, error)
CollectMessagesContext starts a bounded message collector tied to ctx and the client lifecycle.
func (*Client) CollectReactions ¶
func (c *Client) CollectReactions(options ReactionCollectorOptions) (*ReactionCollector, error)
CollectReactions starts a bounded reaction snapshot collector.
func (*Client) CollectReactionsContext ¶
func (c *Client) CollectReactionsContext(ctx context.Context, options ReactionCollectorOptions) (*ReactionCollector, error)
CollectReactionsContext starts a reaction collector tied to ctx and the client lifecycle.
func (*Client) Done ¶
func (c *Client) Done() <-chan struct{}
Done closes after the client's run and shutdown cleanup have completed.
func (*Client) DroppedEvents ¶
DroppedEvents returns the number of updates discarded because the bounded event queue was full.
func (*Client) OnChannelDelete ¶
func (c *Client) OnChannelDelete(handler ChannelDeleteHandler) func()
func (*Client) OnChannelUpdate ¶
func (c *Client) OnChannelUpdate(handler ChannelUpdateHandler) func()
func (*Client) OnChatTyping ¶
func (c *Client) OnChatTyping(handler ChatTypingHandler) func()
func (*Client) OnCommunityDelete ¶
func (c *Client) OnCommunityDelete(handler CommunityDeleteHandler) func()
func (*Client) OnCommunityUpdate ¶
func (c *Client) OnCommunityUpdate(handler CommunityUpdateHandler) func()
func (*Client) OnConnected ¶
func (c *Client) OnConnected(handler ConnectionHandler) func()
func (*Client) OnConnecting ¶
func (c *Client) OnConnecting(handler ConnectionHandler) func()
func (*Client) OnConnectionError ¶
func (c *Client) OnConnectionError(handler ConnectionHandler) func()
func (*Client) OnConversationLastRead ¶
func (c *Client) OnConversationLastRead(handler ConversationLastReadHandler) func()
func (*Client) OnDisconnected ¶
func (c *Client) OnDisconnected(handler ConnectionHandler) func()
func (*Client) OnError ¶
func (c *Client) OnError(handler ConnectionHandler) func()
OnError is a short alias for connection errors. Handler failures remain observable through Config.OnHandlerError.
func (*Client) OnInteraction ¶
func (c *Client) OnInteraction(handler InteractionHandler) func()
func (*Client) OnMemberCreate ¶
func (c *Client) OnMemberCreate(handler MemberCreateHandler) func()
func (*Client) OnMemberDelete ¶
func (c *Client) OnMemberDelete(handler MemberDeleteHandler) func()
func (*Client) OnMemberUpdate ¶
func (c *Client) OnMemberUpdate(handler MemberUpdateHandler) func()
func (*Client) OnMessageCreate ¶
func (c *Client) OnMessageCreate(handler MessageCreateHandler) func()
func (*Client) OnMessageDelete ¶
func (c *Client) OnMessageDelete(handler MessageDeleteHandler) func()
func (*Client) OnMessageReactions ¶
func (c *Client) OnMessageReactions(handler MessageReactionsHandler) func()
func (*Client) OnMessageUpdate ¶
func (c *Client) OnMessageUpdate(handler MessageUpdateHandler) func()
func (*Client) OnReady ¶
func (c *Client) OnReady(handler ReadyHandler) func()
func (*Client) OnReconnecting ¶
func (c *Client) OnReconnecting(handler ConnectionHandler) func()
func (*Client) OnUpdate ¶
func (c *Client) OnUpdate(handler UpdateHandler) func()
func (*Client) OnUserUpdate ¶
func (c *Client) OnUserUpdate(handler UserUpdateHandler) func()
func (*Client) OnVoiceRoomParticipant ¶
func (c *Client) OnVoiceRoomParticipant(handler VoiceRoomParticipantHandler) func()
func (*Client) OnVoiceRoomState ¶
func (c *Client) OnVoiceRoomState(handler VoiceRoomStateHandler) func()
func (*Client) Run ¶
Run owns the connection lifecycle until ctx is canceled, Close is called, or a permanent protocol error is returned. It may be called only once per Client; use a new Client for a new lifecycle.
type CollectorError ¶
type CollectorError = collectors.CollectorError
type CollectorResult ¶
type CollectorResult = collectors.CollectorResult
type CommunityDeleteEvent ¶
type CommunityDeleteEvent = eventtypes.CommunityDeleteEvent
type CommunityDeleteHandler ¶
type CommunityDeleteHandler = eventtypes.CommunityDeleteHandler
type CommunityUpdateEvent ¶
type CommunityUpdateEvent = eventtypes.CommunityUpdateEvent
type CommunityUpdateHandler ¶
type CommunityUpdateHandler = eventtypes.CommunityUpdateHandler
type Config ¶
type Config struct {
Token string
ClientID uint32
ServerURL string
Logger *slog.Logger
OnHandlerError HandlerErrorHandler
OnEventOverflow EventOverflowHandler
RequestTimeout time.Duration
RequestInterval time.Duration
HeartbeatInterval time.Duration
EventQueue int
EventWorkers int
WriteQueue int
WriteTimeout time.Duration
ReadLimit int64
DialTimeout time.Duration
StableConnection time.Duration
BackoffMin time.Duration
BackoffMax time.Duration
DeviceType string
DeviceVersion string
AppVersion string
// contains filtered or unexported fields
}
Config controls a Client. Zero values use sensible defaults.
type ConnectionEvent ¶
type ConnectionEvent = eventtypes.ConnectionEvent
type ConnectionHandler ¶
type ConnectionHandler = eventtypes.ConnectionHandler
type ConversationLastReadEvent ¶
type ConversationLastReadEvent = eventtypes.ConversationLastReadEvent
type ConversationLastReadHandler ¶
type ConversationLastReadHandler = eventtypes.ConversationLastReadHandler
type EndReason ¶
type EndReason = collectors.EndReason
type EventOverflowHandler ¶
type EventOverflowHandler = eventtypes.EventOverflowHandler
type HandlerError ¶
type HandlerError = eventtypes.HandlerError
type HandlerErrorHandler ¶
type HandlerErrorHandler = eventtypes.HandlerErrorHandler
type InteractionCollector ¶
type InteractionCollector = collectors.InteractionCollector
type InteractionCollectorOptions ¶
type InteractionCollectorOptions = collectors.InteractionCollectorOptions
type InteractionEvent ¶
type InteractionEvent = eventtypes.InteractionEvent
type InteractionHandler ¶
type InteractionHandler = eventtypes.InteractionHandler
type MemberCreateEvent ¶
type MemberCreateEvent = eventtypes.MemberCreateEvent
type MemberCreateHandler ¶
type MemberCreateHandler = eventtypes.MemberCreateHandler
type MemberDeleteEvent ¶
type MemberDeleteEvent = eventtypes.MemberDeleteEvent
type MemberDeleteHandler ¶
type MemberDeleteHandler = eventtypes.MemberDeleteHandler
type MemberUpdateEvent ¶
type MemberUpdateEvent = eventtypes.MemberUpdateEvent
type MemberUpdateHandler ¶
type MemberUpdateHandler = eventtypes.MemberUpdateHandler
type MessageCollector ¶
type MessageCollector = collectors.MessageCollector
type MessageCollectorOptions ¶
type MessageCollectorOptions = collectors.MessageCollectorOptions
type MessageCreateEvent ¶
type MessageCreateEvent = eventtypes.MessageCreateEvent
type MessageCreateHandler ¶
type MessageCreateHandler = eventtypes.MessageCreateHandler
type MessageDeleteEvent ¶
type MessageDeleteEvent = eventtypes.MessageDeleteEvent
type MessageDeleteHandler ¶
type MessageDeleteHandler = eventtypes.MessageDeleteHandler
type MessageReactionsEvent ¶
type MessageReactionsEvent = eventtypes.MessageReactionsEvent
type MessageReactionsHandler ¶
type MessageReactionsHandler = eventtypes.MessageReactionsHandler
type MessageUpdateEvent ¶
type MessageUpdateEvent = eventtypes.MessageUpdateEvent
type MessageUpdateHandler ¶
type MessageUpdateHandler = eventtypes.MessageUpdateHandler
type PermanentError ¶
type PermanentError struct{ Err error }
PermanentError marks an error that should not be retried by Client.Run. Its cause remains available through errors.Is and errors.As.
func (*PermanentError) Error ¶
func (e *PermanentError) Error() string
func (*PermanentError) Is ¶
func (e *PermanentError) Is(target error) bool
func (*PermanentError) Unwrap ¶
func (e *PermanentError) Unwrap() error
type RawClient ¶
type RawClient struct {
// contains filtered or unexported fields
}
RawClient is the escape hatch for generated protobuf requests not wrapped by a high-level service yet.
type ReactionCollector ¶
type ReactionCollector = collectors.ReactionCollector
type ReactionCollectorOptions ¶
type ReactionCollectorOptions = collectors.ReactionCollectorOptions
type ReadyEvent ¶
type ReadyEvent = eventtypes.ReadyEvent
type ReadyHandler ¶
type ReadyHandler = eventtypes.ReadyHandler
type UnexpectedResultError ¶
type UnexpectedResultError = rpc.UnexpectedResultError
UnexpectedResultError means the server answered with a result different from the one defined for the requested method.
type UpdateEvent ¶
type UpdateEvent = eventtypes.UpdateEvent
type UpdateHandler ¶
type UpdateHandler = eventtypes.UpdateHandler
type UserUpdateEvent ¶
type UserUpdateEvent = eventtypes.UserUpdateEvent
type UserUpdateHandler ¶
type UserUpdateHandler = eventtypes.UserUpdateHandler
type VoiceRoomParticipantEvent ¶
type VoiceRoomParticipantEvent = eventtypes.VoiceRoomParticipantEvent
type VoiceRoomParticipantHandler ¶
type VoiceRoomParticipantHandler = eventtypes.VoiceRoomParticipantHandler
type VoiceRoomStateEvent ¶
type VoiceRoomStateEvent = eventtypes.VoiceRoomStateEvent
type VoiceRoomStateHandler ¶
type VoiceRoomStateHandler = eventtypes.VoiceRoomStateHandler