Documentation
¶
Overview ¶
Package hub implements the central event hub for cdev.
Package hub implements the central event hub for cdev.
Index ¶
- type ChannelSubscriber
- type FilteredSubscriber
- func (f *FilteredSubscriber) ClearSessionFocus()
- func (f *FilteredSubscriber) ClearSessionFocusIfWorkspace(workspaceID string) bool
- func (f *FilteredSubscriber) Close() error
- func (f *FilteredSubscriber) Done() <-chan struct{}
- func (f *FilteredSubscriber) GetFocusedSessionID() (string, bool)
- func (f *FilteredSubscriber) GetSubscribedWorkspaces() []string
- func (f *FilteredSubscriber) ID() string
- func (f *FilteredSubscriber) IsFiltering() bool
- func (f *FilteredSubscriber) Send(event events.Event) error
- func (f *FilteredSubscriber) SetSessionFocus(workspaceID, sessionID string)
- func (f *FilteredSubscriber) SubscribeAll()
- func (f *FilteredSubscriber) SubscribeWorkspace(workspaceID string)
- func (f *FilteredSubscriber) UnsubscribeWorkspace(workspaceID string)
- type Hub
- type LogSubscriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelSubscriber ¶
type ChannelSubscriber struct {
// contains filtered or unexported fields
}
ChannelSubscriber is a subscriber that sends events to a channel.
func NewChannelSubscriber ¶
func NewChannelSubscriber(id string, bufferSize int) *ChannelSubscriber
NewChannelSubscriber creates a new channel-based subscriber.
func (*ChannelSubscriber) Close ¶
func (s *ChannelSubscriber) Close() error
Close closes the subscriber.
func (*ChannelSubscriber) Done ¶
func (s *ChannelSubscriber) Done() <-chan struct{}
Done returns a channel that's closed when the subscriber is done.
func (*ChannelSubscriber) Events ¶
func (s *ChannelSubscriber) Events() <-chan events.Event
Events returns the channel to receive events from.
func (*ChannelSubscriber) ID ¶
func (s *ChannelSubscriber) ID() string
ID returns the subscriber's unique identifier.
type FilteredSubscriber ¶
type FilteredSubscriber struct {
// contains filtered or unexported fields
}
FilteredSubscriber wraps a subscriber and filters events by workspace ID and optionally by focused workspace for permission events. Events without a workspace ID (global events) are always forwarded. If no workspaces are subscribed, all events are forwarded (backward compatible). Permission filtering only applies to pty_permission and pty_permission_resolved events. When a client has a focused workspace, permission events from any session in that workspace are forwarded (enabling multi-session badge indicators on iOS). Clients that never call SetSessionFocus receive all permission events (backward compatible).
func NewFilteredSubscriber ¶
func NewFilteredSubscriber(inner ports.Subscriber) *FilteredSubscriber
NewFilteredSubscriber creates a new filtered subscriber wrapping the given subscriber.
func (*FilteredSubscriber) ClearSessionFocus ¶
func (f *FilteredSubscriber) ClearSessionFocus()
ClearSessionFocus removes session focus, reverting to pass-all behavior for permission events.
func (*FilteredSubscriber) ClearSessionFocusIfWorkspace ¶
func (f *FilteredSubscriber) ClearSessionFocusIfWorkspace(workspaceID string) bool
ClearSessionFocusIfWorkspace clears session focus only if the focused session belongs to the given workspace. Returns true if focus was cleared. Guards against empty workspaceID to prevent accidental clearing.
func (*FilteredSubscriber) Close ¶
func (f *FilteredSubscriber) Close() error
Close closes the subscriber.
func (*FilteredSubscriber) Done ¶
func (f *FilteredSubscriber) Done() <-chan struct{}
Done returns a channel that's closed when the subscriber is done.
func (*FilteredSubscriber) GetFocusedSessionID ¶
func (f *FilteredSubscriber) GetFocusedSessionID() (string, bool)
GetFocusedSessionID returns the focused session ID and whether focus is set.
func (*FilteredSubscriber) GetSubscribedWorkspaces ¶
func (f *FilteredSubscriber) GetSubscribedWorkspaces() []string
GetSubscribedWorkspaces returns the list of subscribed workspace IDs.
func (*FilteredSubscriber) ID ¶
func (f *FilteredSubscriber) ID() string
ID returns the subscriber's unique identifier.
func (*FilteredSubscriber) IsFiltering ¶
func (f *FilteredSubscriber) IsFiltering() bool
IsFiltering returns true if the subscriber is filtering by workspace.
func (*FilteredSubscriber) Send ¶
func (f *FilteredSubscriber) Send(event events.Event) error
Send sends an event to the subscriber if it passes the filter.
func (*FilteredSubscriber) SetSessionFocus ¶
func (f *FilteredSubscriber) SetSessionFocus(workspaceID, sessionID string)
SetSessionFocus sets the session and workspace the client is focused on. Only pty_permission and pty_permission_resolved events are workspace-filtered.
func (*FilteredSubscriber) SubscribeAll ¶
func (f *FilteredSubscriber) SubscribeAll()
SubscribeAll clears the filter, forwarding all events (default behavior).
func (*FilteredSubscriber) SubscribeWorkspace ¶
func (f *FilteredSubscriber) SubscribeWorkspace(workspaceID string)
SubscribeWorkspace adds a workspace to the filter. Events for this workspace will be forwarded to the subscriber.
func (*FilteredSubscriber) UnsubscribeWorkspace ¶
func (f *FilteredSubscriber) UnsubscribeWorkspace(workspaceID string)
UnsubscribeWorkspace removes a workspace from the filter.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub is the central event dispatcher that fans out events to all subscribers.
func (*Hub) Subscribe ¶
func (h *Hub) Subscribe(sub ports.Subscriber)
Subscribe adds a new subscriber.
func (*Hub) SubscriberCount ¶
SubscriberCount returns the number of active subscribers.
func (*Hub) Unsubscribe ¶
Unsubscribe removes a subscriber by ID.
type LogSubscriber ¶
type LogSubscriber struct {
// contains filtered or unexported fields
}
LogSubscriber is a subscriber that logs events (useful for debugging).
func NewLogSubscriber ¶
func NewLogSubscriber(id string, logFn func(event events.Event)) *LogSubscriber
NewLogSubscriber creates a new log subscriber.
func (*LogSubscriber) Done ¶
func (s *LogSubscriber) Done() <-chan struct{}
Done returns a channel that's closed when the subscriber is done.
func (*LogSubscriber) ID ¶
func (s *LogSubscriber) ID() string
ID returns the subscriber's unique identifier.