hub

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLogLevel = logLevelInfoValue

DefaultLogLevel is used when runtime config omits log_level.

Variables

This section is empty.

Functions

func AllowNonMoltenHubBaseURL

func AllowNonMoltenHubBaseURL() bool

AllowNonMoltenHubBaseURL reports whether non-production hub base URLs are explicitly allowed (for local integration/testing).

func ApplyBoundAgentRuntime

func ApplyBoundAgentRuntime(runCfg config.Config, initCfg InitConfig) (config.Config, error)

ApplyBoundAgentRuntime enforces single-agent binding for one run request when this runtime already has a bound agent harness. If the runtime is still unbound, the request config is passed through unchanged.

func BoundAgentRuntime

func BoundAgentRuntime(initCfg InitConfig) (agentruntime.Runtime, error)

BoundAgentRuntime resolves the configured one-agent runtime for this app instance.

func CanonicalHubBaseURL

func CanonicalHubBaseURL(baseURL string) (string, error)

CanonicalHubBaseURL validates and normalizes baseURL according to active policy.

func ClearRuntimeConfigHubSettings

func ClearRuntimeConfigHubSettings(path string, initCfg InitConfig) error

ClearRuntimeConfigHubSettings removes saved Hub identity, credentials, and profile fields while preserving unrelated runtime configuration.

func HubBaseURLForRegion

func HubBaseURLForRegion(region string) string

HubBaseURLForRegion returns the canonical hub API base URL for a region.

func HubRegionFromBaseURL

func HubRegionFromBaseURL(baseURL string) string

HubRegionFromBaseURL infers region from a hub base URL.

func IncrementRuntimeConfigLibraryTaskUsage

func IncrementRuntimeConfigLibraryTaskUsage(path string, initCfg InitConfig, taskName string) error

IncrementRuntimeConfigLibraryTaskUsage records one successful local selection of a library task in config.json while preserving unrelated runtime config settings already stored on disk.

func NormalizeHubRegion

func NormalizeHubRegion(region string) string

NormalizeHubRegion converts region into a supported value.

func NormalizeLogLevel

func NormalizeLogLevel(raw string) string

NormalizeLogLevel canonicalizes supported spellings/aliases.

func ParseRunConfigJSON

func ParseRunConfigJSON(payload []byte) (config.Config, error)

ParseRunConfigJSON parses one inline run config JSON object into a validated config.

func ReadRuntimeConfigLibraryTaskUsage

func ReadRuntimeConfigLibraryTaskUsage(path string) map[string]int

ReadRuntimeConfigLibraryTaskUsage returns normalized per-task usage counts from the persisted runtime config. Invalid or non-positive entries are ignored.

func ReadRuntimeConfigString

func ReadRuntimeConfigString(path string, keys ...string) string

ReadRuntimeConfigString returns the first non-empty string for the provided keys from a runtime config file. It returns an empty string when the file cannot be read or parsed.

func ResolveRuntimeConfigPath

func ResolveRuntimeConfigPath(initPath string) string

func RunCompletedActivity

func RunCompletedActivity(runCfg config.Config) string

RunCompletedActivity returns the custom task-complete activity for runCfg.

func RunStartedActivity

func RunStartedActivity(runCfg config.Config) string

RunStartedActivity returns the custom task-start activity for runCfg.

func SaveRuntimeConfig

func SaveRuntimeConfig(path string, initCfg InitConfig, token string) error

SaveRuntimeConfig writes a normalized, hub-bootable runtime config JSON file.

func SaveRuntimeConfigAgentRuntime

func SaveRuntimeConfigAgentRuntime(path string, initCfg InitConfig, harness, command string) error

SaveRuntimeConfigAgentRuntime persists agent_harness/agent_command to the runtime config while preserving other configuration fields. Once configured, switching to a different harness or command through this API is rejected.

func SaveRuntimeConfigClaudeOAuthToken

func SaveRuntimeConfigClaudeOAuthToken(path string, initCfg InitConfig, oauthToken string) error

SaveRuntimeConfigClaudeOAuthToken persists claude_code_oauth_token to the runtime config JSON while preserving other configuration fields.

func SaveRuntimeConfigGitHubToken

func SaveRuntimeConfigGitHubToken(path string, initCfg InitConfig, gitHubToken string) error

SaveRuntimeConfigGitHubToken persists github_token to the runtime config JSON while preserving other configuration fields.

func SaveRuntimeConfigHubSettings

func SaveRuntimeConfigHubSettings(path string, initCfg InitConfig, resolvedAgentToken string) error

SaveRuntimeConfigHubSettings persists hub credentials plus handle/profile fields while preserving unrelated runtime config keys already on disk.

func SaveRuntimeConfigReviewSettings added in v1.0.13

func SaveRuntimeConfigReviewSettings(path string, initCfg InitConfig, reviewCfg ReviewWatchConfig) error

SaveRuntimeConfigReviewSettings persists user-editable review automation settings while omitting fields whose values match runtime defaults.

func ValidateHubBaseURL

func ValidateHubBaseURL(baseURL string) error

ValidateHubBaseURL validates baseURL according to the active policy.

func ValidateHubBaseURLStrict

func ValidateHubBaseURLStrict(baseURL string) error

ValidateHubBaseURLStrict validates baseURL against production hub constraints.

func ValidatePersistedHubBaseURL

func ValidatePersistedHubBaseURL(baseURL string) error

ValidatePersistedHubBaseURL validates hub base URLs that may be written to runtime config. Persisted config must stay on HTTPS Molten Hub domains even when local non-Molten endpoints are allowed for in-process tests.

func WebsocketURL

func WebsocketURL(baseURL, sessionKey string) (string, error)

WebsocketURL builds the canonical runtime websocket endpoint from API base URL.

Types

type APIClient

type APIClient struct {
	BaseURL    string
	HTTPClient *http.Client
	Logf       func(string, ...any)
}

APIClient wraps hub HTTP interactions.

func NewAPIClient

func NewAPIClient(baseURL string) APIClient

NewAPIClient returns an API client with defaults.

func (APIClient) AckRuntimeDelivery

func (c APIClient) AckRuntimeDelivery(ctx context.Context, token, deliveryID string) error

AckRuntimeDelivery acknowledges a leased pull delivery.

func (APIClient) AgentMetadata

func (c APIClient) AgentMetadata(ctx context.Context, token string) (map[string]any, error)

AgentMetadata loads the current agent metadata for safe merge-style updates.

func (APIClient) AgentProfile

func (c APIClient) AgentProfile(ctx context.Context, token string) (AgentProfile, error)

AgentProfile loads the current agent handle/profile for config persistence.

func (APIClient) Health

func (c APIClient) Health(ctx context.Context) error

Health checks hub health at /health.

func (APIClient) MarkRuntimeOffline

func (c APIClient) MarkRuntimeOffline(ctx context.Context, token, sessionKey, reason string) error

MarkRuntimeOffline marks this runtime offline for websocket transport.

func (APIClient) NackRuntimeDelivery

func (c APIClient) NackRuntimeDelivery(ctx context.Context, token, deliveryID string) error

NackRuntimeDelivery releases a leased pull delivery back to the queue.

func (APIClient) Ping

func (c APIClient) Ping(ctx context.Context) error

Ping checks hub liveness at /ping.

func (APIClient) PublishResult

func (c APIClient) PublishResult(ctx context.Context, token string, payload map[string]any) error

PublishResult posts a skill result using A2A SendMessage with runtime transport fallback.

func (APIClient) PullRuntimeMessage

func (c APIClient) PullRuntimeMessage(ctx context.Context, token string, timeoutMs int) (PulledRuntimeMessage, bool, error)

PullRuntimeMessage claims the next runtime envelope using long-poll transport.

func (APIClient) RecordActivity

func (c APIClient) RecordActivity(ctx context.Context, token, activity string) error

RecordActivity publishes a custom activity entry.

func (APIClient) RecordCodingActivityRunning

func (c APIClient) RecordCodingActivityRunning(ctx context.Context, token string) error

RecordCodingActivityRunning publishes a generic active-coding activity.

func (APIClient) RecordGitHubTaskCompleteActivity

func (c APIClient) RecordGitHubTaskCompleteActivity(ctx context.Context, token string) error

RecordGitHubTaskCompleteActivity publishes a minimal completion activity.

func (APIClient) RecordRunCompletedActivity

func (c APIClient) RecordRunCompletedActivity(ctx context.Context, token string, runCfg config.Config) error

RecordRunCompletedActivity publishes the standard activity entry for one completed task run.

func (APIClient) RecordRunStartedActivity

func (c APIClient) RecordRunStartedActivity(ctx context.Context, token string, runCfg config.Config) error

RecordRunStartedActivity publishes the standard activity entry for one task run.

func (APIClient) RegisterRuntime

func (c APIClient) RegisterRuntime(ctx context.Context, token string, cfg InitConfig, libraryTasks []library.TaskSummary) error

RegisterRuntime sends plugin/runtime metadata to hub.

func (*APIClient) ResolveAgentToken

func (c *APIClient) ResolveAgentToken(ctx context.Context, cfg InitConfig) (string, error)

ResolveAgentToken picks a working agent token from init config and bind flow.

func (APIClient) SyncProfile

func (c APIClient) SyncProfile(ctx context.Context, token string, cfg InitConfig) error

SyncProfile applies handle/profile updates.

func (APIClient) UpdateAgentStatus

func (c APIClient) UpdateAgentStatus(ctx context.Context, token, status string) error

UpdateAgentStatus updates the hub-visible lifecycle status for this agent.

type AdaptiveDispatchController

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

AdaptiveDispatchController controls dispatch admission with rolling system load samples. It never preempts running work; when pressure rises, newer tasks stay queued.

func NewAdaptiveDispatchController

func NewAdaptiveDispatchController(cfg DispatcherConfig, logf func(string, ...any)) *AdaptiveDispatchController

NewAdaptiveDispatchController returns a queue-aware, adaptive dispatcher.

func (*AdaptiveDispatchController) Acquire

func (c *AdaptiveDispatchController) Acquire(ctx context.Context, requestID string) (func(), error)

Acquire blocks until the caller is admitted to run. The returned function must be called once when done.

func (*AdaptiveDispatchController) AcquireForce

func (c *AdaptiveDispatchController) AcquireForce(ctx context.Context, requestID string) (func(), error)

AcquireForce admits a caller immediately, even when current running work exceeds allowed capacity. Use this sparingly for explicit operator override actions.

func (*AdaptiveDispatchController) Start

Start begins background sampling. Safe to call multiple times.

type AgentProfile

type AgentProfile struct {
	Handle  string
	Profile ProfileConfig
}

AgentProfile captures the profile fields this runtime needs to persist locally.

type AsyncAPIClient

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

AsyncAPIClient wraps APIClient with token-bound methods and async helpers.

func NewAsyncAPIClient

func NewAsyncAPIClient(baseURL, token string) *AsyncAPIClient

NewAsyncAPIClient returns a token-bound async hub API wrapper.

func NewAsyncAPIClientFrom

func NewAsyncAPIClientFrom(client APIClient, token string) *AsyncAPIClient

NewAsyncAPIClientFrom wraps an existing transport-level API client.

func (*AsyncAPIClient) AckRuntimeDelivery

func (c *AsyncAPIClient) AckRuntimeDelivery(ctx context.Context, deliveryID string) error

AckRuntimeDelivery acknowledges a leased delivery.

func (*AsyncAPIClient) AckRuntimeDeliveryAsync

func (c *AsyncAPIClient) AckRuntimeDeliveryAsync(ctx context.Context, deliveryID string) <-chan error

AckRuntimeDeliveryAsync acknowledges a delivery on a background goroutine.

func (*AsyncAPIClient) BaseURL

func (c *AsyncAPIClient) BaseURL() string

BaseURL returns the normalized API base URL.

func (*AsyncAPIClient) MarkRuntimeOffline

func (c *AsyncAPIClient) MarkRuntimeOffline(ctx context.Context, sessionKey, reason string) error

MarkRuntimeOffline marks websocket transport offline for the configured token.

func (*AsyncAPIClient) NackRuntimeDelivery

func (c *AsyncAPIClient) NackRuntimeDelivery(ctx context.Context, deliveryID string) error

NackRuntimeDelivery releases a leased delivery back to the queue.

func (*AsyncAPIClient) NackRuntimeDeliveryAsync

func (c *AsyncAPIClient) NackRuntimeDeliveryAsync(ctx context.Context, deliveryID string) <-chan error

NackRuntimeDeliveryAsync releases a delivery on a background goroutine.

func (*AsyncAPIClient) PublishResult

func (c *AsyncAPIClient) PublishResult(ctx context.Context, payload map[string]any) error

PublishResult publishes a skill result for the configured token.

func (*AsyncAPIClient) PublishResultAsync

func (c *AsyncAPIClient) PublishResultAsync(ctx context.Context, payload map[string]any) <-chan error

PublishResultAsync publishes a result on a background goroutine.

func (*AsyncAPIClient) PullRuntimeMessage

func (c *AsyncAPIClient) PullRuntimeMessage(ctx context.Context, timeoutMs int) (PulledRuntimeMessage, bool, error)

PullRuntimeMessage pulls one inbound transport envelope.

func (*AsyncAPIClient) RecordActivity

func (c *AsyncAPIClient) RecordActivity(ctx context.Context, activity string) error

RecordActivity publishes a custom agent activity.

func (*AsyncAPIClient) RecordCodingActivityRunning

func (c *AsyncAPIClient) RecordCodingActivityRunning(ctx context.Context) error

RecordCodingActivityRunning publishes a generic active-coding activity.

func (*AsyncAPIClient) RecordGitHubTaskCompleteActivity

func (c *AsyncAPIClient) RecordGitHubTaskCompleteActivity(ctx context.Context) error

RecordGitHubTaskCompleteActivity publishes a minimal completion activity.

func (*AsyncAPIClient) RecordRunCompletedActivity

func (c *AsyncAPIClient) RecordRunCompletedActivity(ctx context.Context, runCfg config.Config) error

RecordRunCompletedActivity publishes the standard activity entry for one completed task run.

func (*AsyncAPIClient) RecordRunStartedActivity

func (c *AsyncAPIClient) RecordRunStartedActivity(ctx context.Context, runCfg config.Config) error

RecordRunStartedActivity publishes the standard activity entry for one task run.

func (*AsyncAPIClient) RegisterRuntime

func (c *AsyncAPIClient) RegisterRuntime(ctx context.Context, cfg InitConfig, libraryTasks []library.TaskSummary) error

RegisterRuntime registers runtime metadata for the configured token.

func (*AsyncAPIClient) ResolveAgentToken

func (c *AsyncAPIClient) ResolveAgentToken(ctx context.Context, cfg InitConfig) (string, error)

ResolveAgentToken resolves and stores a working token for subsequent calls.

func (*AsyncAPIClient) SyncProfile

func (c *AsyncAPIClient) SyncProfile(ctx context.Context, cfg InitConfig) error

SyncProfile syncs profile metadata for the configured token.

func (*AsyncAPIClient) Token

func (c *AsyncAPIClient) Token() string

Token returns the currently configured bearer token.

func (*AsyncAPIClient) UpdateAgentStatus

func (c *AsyncAPIClient) UpdateAgentStatus(ctx context.Context, status string) error

UpdateAgentStatus updates agent lifecycle status for the configured token.

type Daemon

type Daemon struct {
	Runner              execx.Runner
	Logf                func(string, ...any)
	OnDispatchQueued    func(requestID string, runCfg config.Config)
	OnDispatchFailed    func(requestID string, runCfg config.Config, result app.Result)
	RegisterTaskControl func(requestID string, cancel context.CancelCauseFunc) DispatchTaskControl
	RegisterTaskAliases func(requestID string, aliases ...string)
	CancelTaskControl   func(taskID string) (requestID string, stopped bool)
	CompleteTaskControl func(requestID string)
	DispatchController  *AdaptiveDispatchController
	ReconnectDelay      time.Duration
	TaskLogRoot         string
}

Daemon listens for hub skill dispatches and runs harness jobs.

func NewDaemon

func NewDaemon(runner execx.Runner) Daemon

NewDaemon returns a hub daemon with defaults.

func (Daemon) Run

func (d Daemon) Run(ctx context.Context, cfg InitConfig) error

Run binds/auths, syncs profile, then consumes websocket transport (with pull fallback) for skill runs.

type DispatchTaskControl

type DispatchTaskControl interface {
	WaitUntilRunnable(context.Context) error
	SetAcquireCancel(context.CancelFunc)
	ClearAcquireCancel(context.CancelFunc)
	SetRunning(bool)
	ConsumeForceAcquire() bool
	HasForceAcquire() bool
	IsPaused() bool
	IsStopped() bool
}

DispatchTaskControl exposes per-request runtime controls shared with the UI.

type DispatcherConfig

type DispatcherConfig struct {
	MaxParallel            int     `json:"max_parallel"`
	MinParallel            int     `json:"min_parallel"`
	SampleWindow           int     `json:"sample_window"`
	SampleIntervalMS       int     `json:"sample_interval_ms"`
	CPUHighWatermark       float64 `json:"cpu_high_watermark"`
	MemoryHighWatermark    float64 `json:"memory_high_watermark"`
	DiskIOHighWatermarkMBs float64 `json:"disk_io_high_watermark_mb_s"`
}

DispatcherConfig controls local worker behavior.

type InitConfig

type InitConfig struct {
	Version           string            `json:"version"`
	BaseURL           string            `json:"base_url"`
	BindToken         string            `json:"bind_token"`
	AgentToken        string            `json:"agent_token"`
	LogLevel          string            `json:"log_level,omitempty"`
	AgentHarness      string            `json:"agent_harness,omitempty"`
	AgentCommand      string            `json:"agent_command,omitempty"`
	SessionKey        string            `json:"session_key"`
	Handle            string            `json:"handle"`
	Profile           ProfileConfig     `json:"profile"`
	GitHubToken       string            `json:"github_token,omitempty"`
	OpenAIAPIKey      string            `json:"openai_api_key,omitempty"`
	Skill             SkillConfig       `json:"-"`
	RuntimeConfigPath string            `json:"-"`
	Dispatcher        DispatcherConfig  `json:"dispatcher"`
	ReviewWatch       ReviewWatchConfig `json:"review_watch,omitempty"`
}

InitConfig is the init.json contract for hub runtime mode.

func LoadInit

func LoadInit(path string) (InitConfig, error)

LoadInit reads and validates JSON/JSONC init config.

func (*InitConfig) ApplyDefaults

func (c *InitConfig) ApplyDefaults()

ApplyDefaults normalizes and fills optional values.

func (InitConfig) Validate

func (c InitConfig) Validate() error

Validate checks required values.

type LogLevel

type LogLevel int

LogLevel controls log emission severity filtering.

const (
	LogLevelDebug LogLevel = iota
	LogLevelInfo
	LogLevelWarn
	LogLevelError
)

func ParseLogLevel

func ParseLogLevel(raw string) (LogLevel, error)

ParseLogLevel returns a canonical level enum for a configured value.

func (LogLevel) Allows

func (l LogLevel) Allows(eventLevel LogLevel) bool

Allows reports whether an event at eventLevel should be emitted.

func (LogLevel) String

func (l LogLevel) String() string

String returns the canonical lower-case string.

type MoltenHubAPI

type MoltenHubAPI interface {
	BaseURL() string
	Token() string

	ResolveAgentToken(ctx context.Context, cfg InitConfig) (string, error)
	SyncProfile(ctx context.Context, cfg InitConfig) error
	UpdateAgentStatus(ctx context.Context, status string) error
	MarkRuntimeOffline(ctx context.Context, sessionKey, reason string) error
	RecordActivity(ctx context.Context, activity string) error
	RecordCodingActivityRunning(ctx context.Context) error
	RecordGitHubTaskCompleteActivity(ctx context.Context) error
	RecordRunStartedActivity(ctx context.Context, runCfg config.Config) error
	RecordRunCompletedActivity(ctx context.Context, runCfg config.Config) error
	RegisterRuntime(ctx context.Context, cfg InitConfig, libraryTasks []library.TaskSummary) error
	PublishResult(ctx context.Context, payload map[string]any) error
	PublishResultAsync(ctx context.Context, payload map[string]any) <-chan error
	PullRuntimeMessage(ctx context.Context, timeoutMs int) (PulledRuntimeMessage, bool, error)
	AckRuntimeDelivery(ctx context.Context, deliveryID string) error
	AckRuntimeDeliveryAsync(ctx context.Context, deliveryID string) <-chan error
	NackRuntimeDelivery(ctx context.Context, deliveryID string) error
	NackRuntimeDeliveryAsync(ctx context.Context, deliveryID string) <-chan error
}

MoltenHubAPI defines the runtime hub API surface with token-bound calls. Async methods return a buffered channel with one terminal error value.

type ProfileConfig

type ProfileConfig struct {
	DisplayName string         `json:"display_name"`
	Emoji       string         `json:"emoji"`
	ProfileText string         `json:"profile"`
	LLM         string         `json:"llm"`
	Harness     string         `json:"harness"`
	Skills      []string       `json:"skills"`
	Metadata    map[string]any `json:"-"`
}

ProfileConfig controls optional agent profile sync on startup.

func (*ProfileConfig) UnmarshalJSON

func (p *ProfileConfig) UnmarshalJSON(data []byte) error

type PulledRuntimeMessage

type PulledRuntimeMessage struct {
	DeliveryID string
	MessageID  string
	Message    map[string]any
}

PulledRuntimeMessage is one leased inbound message from runtime pull transport.

type ReviewWatchConfig added in v1.0.10

type ReviewWatchConfig struct {
	Enabled        *bool  `json:"enabled,omitempty"`
	PollIntervalMS int    `json:"poll_interval_ms,omitempty"`
	Writeback      string `json:"writeback,omitempty"`
	AutoMerge      *bool  `json:"auto_merge,omitempty"`
	MergeMethod    string `json:"merge_method,omitempty"`
	ResponseMode   string `json:"response_mode,omitempty"`
}

ReviewWatchConfig controls local GitHub notification polling for review requests.

func (ReviewWatchConfig) AutoMergeEnabled added in v1.0.10

func (c ReviewWatchConfig) AutoMergeEnabled() bool

AutoMergeEnabled returns the effective clean-review merge setting.

func (ReviewWatchConfig) EnabledValue added in v1.0.10

func (c ReviewWatchConfig) EnabledValue() bool

EnabledValue returns the effective local review watcher setting. The watcher defaults on so a GitHub-authenticated hub can respond to review requests without extra config.

type RuntimeConfig

type RuntimeConfig struct {
	InitConfig
	TimeoutMs        int            `json:"timeout_ms,omitempty"`
	LibraryTaskUsage map[string]int `json:"library_task_usage,omitempty"`
}

RuntimeConfig is persisted after successful hub auth so subsequent runs can start directly from config.json without requiring init.json again.

func LoadRuntimeConfig

func LoadRuntimeConfig(path string) (RuntimeConfig, error)

LoadRuntimeConfig reads and validates a persisted runtime config JSON file.

func (*RuntimeConfig) ApplyDefaults

func (c *RuntimeConfig) ApplyDefaults()

ApplyDefaults normalizes a persisted runtime config.

func (RuntimeConfig) Init

func (c RuntimeConfig) Init() InitConfig

func (*RuntimeConfig) UnmarshalJSON

func (c *RuntimeConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts the current init-style snake_case config and the legacy minimal runtime config shape.

func (RuntimeConfig) Validate

func (c RuntimeConfig) Validate() error

Validate checks required values for hub boot from config.json.

type SkillConfig

type SkillConfig struct {
	Name         string `json:"name"`
	DispatchType string `json:"dispatch_type"`
	ResultType   string `json:"result_type"`
}

SkillConfig defines the inbound dispatch and outbound result contract.

type SkillDispatch

type SkillDispatch struct {
	RequestID           string
	HubTaskID           string
	ContextID           string
	Skill               string
	ReplyTo             string
	RouteTo             string
	Originator          string
	OriginatorAgentURI  string
	OriginatorAgentUUID string
	OriginatorAgentID   string
	OriginatorHumanID   string
	Config              config.Config
}

SkillDispatch represents one inbound skill request ready for execution.

func ParseSkillDispatch

func ParseSkillDispatch(msg map[string]any, expectedType, expectedSkill string) (SkillDispatch, bool, error)

ParseSkillDispatch parses an inbound transport JSON message into a runnable dispatch.

type WSClient

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

WSClient is a minimal websocket client for text JSON messages.

func DialWebsocket

func DialWebsocket(ctx context.Context, rawURL, bearerToken string) (*WSClient, error)

DialWebsocket creates an authenticated websocket connection.

func (*WSClient) Close

func (c *WSClient) Close() error

Close closes the websocket connection.

func (*WSClient) ReadJSON

func (c *WSClient) ReadJSON(v any) error

ReadJSON reads the next text frame and decodes JSON.

func (*WSClient) WriteJSON

func (c *WSClient) WriteJSON(v any) error

WriteJSON encodes and writes a websocket text frame.

func (*WSClient) WritePing

func (c *WSClient) WritePing(payload []byte) error

WritePing writes a ping control frame.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL