Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) GetLastSync() time.Time
- func (c *Client) GetSyncState() SyncState
- func (c *Client) IsConnected() bool
- func (c *Client) PendingCount() int
- func (c *Client) Run(ctx context.Context) error
- func (c *Client) Stop()
- func (c *Client) SyncDelete(id string) error
- func (c *Client) SyncFullState(ticks map[string]tick.Tick) error
- func (c *Client) SyncTick(t tick.Tick) error
- type Config
- type StateFullMessage
- type SyncFullMessage
- type SyncState
- type TickDeleteMessage
- type TickDeletedMessage
- type TickOperationRequest
- type TickOperationResponse
- type TickUpdateMessage
- type TickUpdatedMessage
Constants ¶
const ( // DefaultCloudURL is the default ticks.sh WebSocket endpoint. DefaultCloudURL = "wss://ticks.sh/api/projects" // EnvToken is the environment variable for the cloud token. EnvToken = "TICKS_TOKEN" // EnvCloudURL is the environment variable to override the cloud URL. EnvCloudURL = "TICKS_URL" // ConfigFileName is the name of the config file in user's home directory. ConfigFileName = ".ticksrc" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Callback for remote changes (optional)
OnRemoteChange func(t tick.Tick)
// State change callback (optional)
OnStateChange func(state SyncState)
// contains filtered or unexported fields
}
Client manages the connection to ticks.sh cloud using sync mode. Sync mode provides real-time tick synchronization via Durable Objects.
func (*Client) Close ¶
Close closes the connection to the cloud with a proper WebSocket close handshake.
func (*Client) GetLastSync ¶ added in v0.7.0
GetLastSync returns the time of the last successful sync.
func (*Client) GetSyncState ¶ added in v0.7.0
GetSyncState returns the current sync state.
func (*Client) IsConnected ¶
IsConnected returns true if the client is currently connected.
func (*Client) PendingCount ¶ added in v0.7.0
PendingCount returns the number of queued messages waiting to be sent.
func (*Client) Run ¶
Run connects to the cloud and handles messages until context is cancelled. It automatically reconnects with exponential backoff on disconnection.
func (*Client) SyncDelete ¶ added in v0.7.0
SyncDelete notifies the DO of a tick deletion.
func (*Client) SyncFullState ¶ added in v0.7.0
SyncFullState sends all ticks to the DO for initial sync.
type Config ¶
type Config struct {
Token string
CloudURL string
BoardName string
TickDir string // path to .tick directory (required)
}
Config holds the cloud client configuration.
func LoadConfig ¶
LoadConfig loads the cloud configuration from environment and config file. Returns nil config if no token is configured (cloud is optional).
type StateFullMessage ¶ added in v0.7.0
type StateFullMessage struct {
Type string `json:"type"` // "state_full"
Ticks map[string]tick.Tick `json:"ticks"`
}
StateFullMessage is received from DO with full tick state.
type SyncFullMessage ¶ added in v0.7.0
type SyncFullMessage struct {
Type string `json:"type"` // "sync_full"
Ticks map[string]tick.Tick `json:"ticks"`
}
SyncFullMessage sends all ticks to the DO for initial sync.
type SyncState ¶ added in v0.7.0
type SyncState int
SyncState represents the connection state for sync mode.
type TickDeleteMessage ¶ added in v0.7.0
TickDeleteMessage notifies DO of tick deletion.
type TickDeletedMessage ¶ added in v0.7.0
type TickDeletedMessage struct {
Type string `json:"type"` // "tick_deleted"
ID string `json:"id"`
}
TickDeletedMessage is received from DO when a tick is deleted.
type TickOperationRequest ¶ added in v0.8.0
type TickOperationRequest struct {
Type string `json:"type"` // "tick_operation"
RequestID string `json:"requestId"` // Unique ID to correlate response
Operation string `json:"operation"` // "add_note", "approve", "reject", "close", "reopen"
TickID string `json:"tickId"` // ID of the tick to operate on
Actor string `json:"actor,omitempty"` // Authenticated session user id (opaque, not an email) of the requester
Payload struct {
Message string `json:"message,omitempty"` // For add_note
Reason string `json:"reason,omitempty"` // For reject, close
} `json:"payload,omitempty"`
}
TickOperationRequest is received from DO when cloud UI wants to perform an operation.
type TickOperationResponse ¶ added in v0.8.0
type TickOperationResponse struct {
Type string `json:"type"` // "tick_operation_response"
RequestID string `json:"requestId"` // Matches the request ID
Success bool `json:"success"` // Whether the operation succeeded
Tick *tick.Tick `json:"tick,omitempty"` // Updated tick on success
Error string `json:"error,omitempty"` // Error message on failure
}
TickOperationResponse is sent back to DO after performing an operation.
type TickUpdateMessage ¶ added in v0.7.0
type TickUpdateMessage struct {
Type string `json:"type"` // "tick_update" or "tick_create"
Tick tick.Tick `json:"tick"`
}
TickUpdateMessage sends a single tick update to the DO.
type TickUpdatedMessage ¶ added in v0.7.0
type TickUpdatedMessage struct {
Type string `json:"type"` // "tick_updated" or "tick_created"
Tick tick.Tick `json:"tick"`
}
TickUpdatedMessage is received from DO when a tick is updated.