Documentation
¶
Overview ¶
Package orbitspace provides the public OrbitSpace REST and SSE client. All calls accept a context. Cancelling observation never cancels a remote task.
Package orbitspace is the Go REST/SSE SDK for OrbitSpace application backends.
Create a Client with an API Token or a ClientCredentials provider. Tasks, Invocations and Goals expose event-driven Observe/Wait helpers; API contains all generated public operations. Wire int64 values remain decimal strings.
Observe/Wait stop at required input, approval, pause or a terminal state. They never automatically approve, reply, resume or cancel remote work. Persist stable idempotency keys and committed event cursors in your own store. Use DownloadFile for bounded, integrity-checked artifact transfers.
Index ¶
- Constants
- func Ptr[T any](v T) *T
- type APIError
- type ArtifactsService
- func (s *ArtifactsService) DownloadFile(ctx context.Context, id, path string, opts DownloadOptions) (DownloadResult, error)
- func (s *ArtifactsService) Get(ctx context.Context, id string) (*api.Artifact, error)
- func (s *ArtifactsService) GetDownload(ctx context.Context, id string) (*api.ArtifactDownload, error)
- type Client
- func (c *Client) DoJSON(ctx context.Context, method, path string, body, out any) error
- func (c *Client) Watch(ctx context.Context, path string, opts WatchOptions, handle func(Event) error) error
- func (c *Client) WatchGoal(ctx context.Context, id string, opts WatchOptions, handle func(Event) error) error
- func (c *Client) WatchInvocation(ctx context.Context, id string, opts WatchOptions, handle func(Event) error) error
- func (c *Client) WatchTask(ctx context.Context, id string, opts WatchOptions, handle func(Event) error) error
- type ClientCredentials
- type ClientCredentialsOptions
- type Destination
- type DownloadOptions
- type DownloadResult
- type DownloadTransportError
- type Event
- type ExecutionState
- type GoalsService
- func (s *GoalsService) Cancel(ctx context.Context, id string, body api.CancelGoalRequest) (*api.Goal, error)
- func (s *GoalsService) Create(ctx context.Context, body api.CreateGoalRequest) (*api.Goal, error)
- func (s *GoalsService) Get(ctx context.Context, id string) (*api.Goal, error)
- func (s *GoalsService) Observe(ctx context.Context, id string, opts ObserveOptions, ...) error
- func (s *GoalsService) Pause(ctx context.Context, id string, body api.PauseGoalRequest) (*api.Goal, error)
- func (s *GoalsService) Resume(ctx context.Context, id string, body api.ResumeGoalRequest) (*api.Goal, error)
- func (s *GoalsService) Start(ctx context.Context, id string, body api.StartGoalRequest) (*api.Goal, error)
- func (s *GoalsService) Wait(ctx context.Context, id string, opts ObserveOptions) (Observation[api.Goal], error)
- type InvocationsService
- func (s *InvocationsService) Cancel(ctx context.Context, id string, body api.CancelInvocationRequest) (*api.Invocation, error)
- func (s *InvocationsService) Create(ctx context.Context, deploymentID string, body api.CreateInvocationRequest) (*api.Invocation, error)
- func (s *InvocationsService) Get(ctx context.Context, id string) (*api.Invocation, error)
- func (s *InvocationsService) Observe(ctx context.Context, id string, opts ObserveOptions, ...) error
- func (s *InvocationsService) Retry(ctx context.Context, id string, body api.RetryInvocationRequest) (*api.Invocation, error)
- func (s *InvocationsService) Wait(ctx context.Context, id string, opts ObserveOptions) (Observation[api.Invocation], error)
- type OAuthError
- type Observation
- type ObserveOptions
- type Options
- type TasksService
- func (s *TasksService) Cancel(ctx context.Context, id string, body api.CancelTaskRequest) (*api.Task, error)
- func (s *TasksService) Create(ctx context.Context, body api.CreateTaskRequest) (*api.Task, error)
- func (s *TasksService) Get(ctx context.Context, id string) (*api.Task, error)
- func (s *TasksService) GetInput(ctx context.Context, id string) (*api.RunInputRequest, error)
- func (s *TasksService) InputRequests(ctx context.Context, id string) (*api.ListTaskInputRequestsResponse, error)
- func (s *TasksService) Observe(ctx context.Context, id string, opts ObserveOptions, ...) error
- func (s *TasksService) Pause(ctx context.Context, id string, body api.PauseTaskRequest) (*api.Task, error)
- func (s *TasksService) ReplyInput(ctx context.Context, id string, body api.ReplyTaskInputRequestRequest) (*api.RunInputRequest, error)
- func (s *TasksService) Resume(ctx context.Context, id string, body api.ResumeTaskRequest) (*api.Task, error)
- func (s *TasksService) Retry(ctx context.Context, id string, body api.RetryTaskRequest) (*api.Task, error)
- func (s *TasksService) Wait(ctx context.Context, id string, opts ObserveOptions) (Observation[api.Task], error)
- type TokenProvider
- type TokenProviderFunc
- type WatchOptions
Constants ¶
const Version = "0.1.0"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArtifactsService ¶
type ArtifactsService struct {
// contains filtered or unexported fields
}
func (*ArtifactsService) DownloadFile ¶
func (s *ArtifactsService) DownloadFile(ctx context.Context, id, path string, opts DownloadOptions) (DownloadResult, error)
DownloadFile obtains a fresh receipt. The API origin's artifact-downloads path is the default destination; external S3/CDN locations require explicit review.
func (*ArtifactsService) GetDownload ¶
func (s *ArtifactsService) GetDownload(ctx context.Context, id string) (*api.ArtifactDownload, error)
type Client ¶
type Client struct {
// API exposes all admitted typed operations. It shares the authenticated transport.
API *api.ClientWithResponses
Tasks *TasksService
Invocations *InvocationsService
Goals *GoalsService
Artifacts *ArtifactsService
// contains filtered or unexported fields
}
func (*Client) DoJSON ¶
DoJSON calls a public API-relative path through the same guarded transport. Prefer API's generated typed methods or the resource helpers below.
func (*Client) Watch ¶
func (c *Client) Watch(ctx context.Context, path string, opts WatchOptions, handle func(Event) error) error
Watch synchronously delivers events. Returning an error stops immediately. Persist a committed cursor only after your handler's business transaction succeeds. A finite or cancellable context is mandatory. No API timeout is applied to SSE.
func (*Client) WatchInvocation ¶
type ClientCredentials ¶
type ClientCredentials struct {
// contains filtered or unexported fields
}
func NewClientCredentials ¶
func NewClientCredentials(opts ClientCredentialsOptions) (*ClientCredentials, error)
func (*ClientCredentials) Invalidate ¶
func (p *ClientCredentials) Invalidate()
Invalidate clears cached credentials. In-flight issuance cannot repopulate the cache.
type Destination ¶
type Destination struct{ Origin, PathPrefix string }
Destination permits one exact origin and a slash-bounded path prefix.
type DownloadOptions ¶
type DownloadOptions struct {
MaxBytes int64 // Mandatory upper bound, independent of declared size.
Destinations []Destination // Mandatory reviewed capability destinations.
HTTPClient *http.Client // No API credentials or tenant headers are supplied.
}
type DownloadResult ¶
func DownloadFile ¶
func DownloadFile(ctx context.Context, receipt api.ArtifactDownload, destination string, opts DownloadOptions) (DownloadResult, error)
DownloadFile verifies a private staging file before atomically replacing destination. Failure or cancellation removes staging and leaves an existing destination untouched.
type DownloadTransportError ¶
type DownloadTransportError struct {
// contains filtered or unexported fields
}
DownloadTransportError redacts capability URLs from ordinary error logs. Unwrap preserves explicit transport diagnostics and errors.Is behavior.
func (*DownloadTransportError) Error ¶
func (e *DownloadTransportError) Error() string
func (*DownloadTransportError) Unwrap ¶
func (e *DownloadTransportError) Unwrap() error
type Event ¶
type Event struct {
ID, Type string
Data json.RawMessage
Retry time.Duration
}
Event.Data is retained verbatim; JSON decoding is a caller decision. ID is the observed cursor, not an acknowledgement of business side effects.
type ExecutionState ¶
type ExecutionState string
const ( StateQueued ExecutionState = "queued" StateRunning ExecutionState = "running" StateWaitingInput ExecutionState = "waiting_input" StateWaitingApproval ExecutionState = "waiting_approval" StatePaused ExecutionState = "paused" StateCompleted ExecutionState = "completed" StateFailed ExecutionState = "failed" StateCancelled ExecutionState = "cancelled" StateUnknown ExecutionState = "unknown" )
func NormalizeState ¶
func NormalizeState(status string) ExecutionState
func (ExecutionState) NeedsAttention ¶
func (s ExecutionState) NeedsAttention() bool
type GoalsService ¶
type GoalsService struct {
// contains filtered or unexported fields
}
func (*GoalsService) Cancel ¶
func (s *GoalsService) Cancel(ctx context.Context, id string, body api.CancelGoalRequest) (*api.Goal, error)
func (*GoalsService) Create ¶
func (s *GoalsService) Create(ctx context.Context, body api.CreateGoalRequest) (*api.Goal, error)
func (*GoalsService) Observe ¶
func (s *GoalsService) Observe(ctx context.Context, id string, opts ObserveOptions, handle func(Observation[api.Goal]) error) error
func (*GoalsService) Pause ¶
func (s *GoalsService) Pause(ctx context.Context, id string, body api.PauseGoalRequest) (*api.Goal, error)
func (*GoalsService) Resume ¶
func (s *GoalsService) Resume(ctx context.Context, id string, body api.ResumeGoalRequest) (*api.Goal, error)
func (*GoalsService) Start ¶
func (s *GoalsService) Start(ctx context.Context, id string, body api.StartGoalRequest) (*api.Goal, error)
func (*GoalsService) Wait ¶
func (s *GoalsService) Wait(ctx context.Context, id string, opts ObserveOptions) (Observation[api.Goal], error)
type InvocationsService ¶
type InvocationsService struct {
// contains filtered or unexported fields
}
func (*InvocationsService) Cancel ¶
func (s *InvocationsService) Cancel(ctx context.Context, id string, body api.CancelInvocationRequest) (*api.Invocation, error)
func (*InvocationsService) Create ¶
func (s *InvocationsService) Create(ctx context.Context, deploymentID string, body api.CreateInvocationRequest) (*api.Invocation, error)
func (*InvocationsService) Get ¶
func (s *InvocationsService) Get(ctx context.Context, id string) (*api.Invocation, error)
func (*InvocationsService) Observe ¶
func (s *InvocationsService) Observe(ctx context.Context, id string, opts ObserveOptions, handle func(Observation[api.Invocation]) error) error
func (*InvocationsService) Retry ¶
func (s *InvocationsService) Retry(ctx context.Context, id string, body api.RetryInvocationRequest) (*api.Invocation, error)
func (*InvocationsService) Wait ¶
func (s *InvocationsService) Wait(ctx context.Context, id string, opts ObserveOptions) (Observation[api.Invocation], error)
type OAuthError ¶
func (*OAuthError) Error ¶
func (e *OAuthError) Error() string
type Observation ¶
type Observation[T any] struct { Resource *T State ExecutionState Cursor string Event *Event }
type ObserveOptions ¶
type ObserveOptions struct {
WatchOptions
MinimumSnapshotInterval time.Duration /* Default 500ms; no idle polling. */
}
type Options ¶
type Options struct {
BaseURL string
Token string
TokenProvider TokenProvider
TenantID string
HTTPClient *http.Client
Headers http.Header
Timeout time.Duration // Defaults to 30s for REST; SSE uses its context lifetime.
MaxErrorBytes int64 // Defaults to 64 KiB.
Retries int // GET/HEAD only, 0..5; default 0.
MaxRetryDelay time.Duration // Defaults to 10s; a longer Retry-After is not shortened.
}
Options never enables automatic retries of writes, including idempotent writes.
type TasksService ¶
type TasksService struct {
// contains filtered or unexported fields
}
func (*TasksService) Cancel ¶
func (s *TasksService) Cancel(ctx context.Context, id string, body api.CancelTaskRequest) (*api.Task, error)
func (*TasksService) Create ¶
func (s *TasksService) Create(ctx context.Context, body api.CreateTaskRequest) (*api.Task, error)
func (*TasksService) GetInput ¶
func (s *TasksService) GetInput(ctx context.Context, id string) (*api.RunInputRequest, error)
func (*TasksService) InputRequests ¶
func (s *TasksService) InputRequests(ctx context.Context, id string) (*api.ListTaskInputRequestsResponse, error)
func (*TasksService) Observe ¶
func (s *TasksService) Observe(ctx context.Context, id string, opts ObserveOptions, handle func(Observation[api.Task]) error) error
func (*TasksService) Pause ¶
func (s *TasksService) Pause(ctx context.Context, id string, body api.PauseTaskRequest) (*api.Task, error)
func (*TasksService) ReplyInput ¶
func (s *TasksService) ReplyInput(ctx context.Context, id string, body api.ReplyTaskInputRequestRequest) (*api.RunInputRequest, error)
func (*TasksService) Resume ¶
func (s *TasksService) Resume(ctx context.Context, id string, body api.ResumeTaskRequest) (*api.Task, error)
func (*TasksService) Retry ¶
func (s *TasksService) Retry(ctx context.Context, id string, body api.RetryTaskRequest) (*api.Task, error)
func (*TasksService) Wait ¶
func (s *TasksService) Wait(ctx context.Context, id string, opts ObserveOptions) (Observation[api.Task], error)