Skip to main content
See Services for usage and limits.

Functions

CreateService()

Create a Service for a running target without retrying. Port zero fails with ErrInvalidConfig before any request. Repeating a create with the same slug and target returns the existing Service while it is enabled. Get and check the Service if ctx ends after the request is sent.

Parameters

slugstring
Service slug, e.g. “my-app”.
The running sandbox and port that receive requests. The port is 1 through 65535.

Returns

The Service as committed.

GetService()

Get a Service by slug.

Parameters

slugstring
Service slug.

Returns

The Service’s current state.

ListServices()

List the first page in slug order, including disabled and detached Services.

Returns

One page of Services.

ListServicesWith()

List a configured page in slug order. A limit outside 1 through 100 fails with ErrInvalidConfig before any request.

Parameters

List options.

Returns

One page of Services.

Service

Accessors use the last response without making a request.

svc.Slug()

The Service slug.

svc.URL()

The public URL as returned by the backend.

svc.Status()

Whether the Service routes requests, is disabled, or has no target, as of the read that returned it. Refresh() returns a current copy.

svc.Target()

The target, or nil when the Service is detached.

svc.CreatedAt()

The creation time.

svc.UpdatedAt()

The last state-change time.

svc.Update()

Change the target without retrying. Port zero fails with ErrInvalidConfig before any request. Get and check the Service if ctx ends after the request is sent.

Parameters

Running target; also enables or reattaches the Service.

Returns

The Service as committed.

svc.Enable()

Enable the Service without retrying. To enable a detached Service, set a running target with Update() instead.

svc.Disable()

Disable the Service without retrying while retaining its target.

svc.Remove()

Remove the Service and release its slug without retrying.

svc.Refresh()

Get the Service again and return its current state. This value is not changed.

Returns

The Service’s current state.

svc.Close()

Release the native handle that this value and its copies share. It does not remove the Service. Later requests from any copy fail with ErrInvalidHandle; accessors still answer. Calling Close is optional: the handle is released once no copy is reachable. It is safe to call more than once.

ServiceListOption

WithServiceListSandbox()

Filter by target sandbox. An unknown name returns an empty page.

WithServiceListLimit()

Set the page size from 1 to 100; the default is 20.

WithServiceListCursor()

Continue from a previous NextCursor.

ServicePage

Services[]*Service
Services in this page, in slug order.
NextCursor*string
Cursor for the next page, or nil on the final page.

ServiceStatus

ServiceStatusEnabled”enabled”
Routes requests to its target.
ServiceStatusDisabled”disabled”
Retains its target without routing requests.
ServiceStatusDetached”detached”
Has no target.
ServiceStatusUnknown”unknown”
The backend returned an unrecognized status.

ServiceTarget

Sandboxstring
Current name of the target sandbox.
Portuint16
Sandbox port, 1 through 65535.

ServiceError

A refused Service change or an unknown outcome. Use errors.As to inspect it; IsKind(err, ErrService) also matches it. Check for a missing Service with IsKind(err, ErrServiceNotFound), an unavailable slug with IsKind(err, ErrServiceAlreadyExists), and a missing target sandbox with IsKind(err, ErrSandboxNotFound).
Slugstring
Service slug.
ReasonServiceErrorReason
Reason for the failure.
RetryAftertime.Duration
Retry delay returned with the refusal, or zero when none was returned.
ChangeUnknown means the change may have been applied; get and check the Service.
RawCodestring
Raw error code returned with a ServiceReasonOther refusal; empty otherwise.
RawStatusint
HTTP status returned with a ServiceReasonOther refusal; zero otherwise.
RawMessagestring
Raw message returned with a ServiceReasonOther refusal; empty otherwise.

Reasons

ServiceReasonQuotaExceeded
The organization’s Service limit was reached. Remove a Service or request a higher limit.
ServiceReasonSandboxLimitExceeded
The target sandbox’s Service limit was reached. Remove or move a Service, or request a higher limit.
ServiceReasonConflict
Another change to the Service committed first. Get it, then retry.
ServiceReasonDetached
The Service is detached. Set a target.
ServiceReasonTargetUnreachable
The target sandbox cannot be reached right now. Retry later, after RetryAfter when set.
ServiceReasonTargetNotRunning
The target sandbox is not running. Start it, then retry.
ServiceReasonChangesPaused
Service changes are paused. Retry later, after RetryAfter when set.
ServiceReasonOutcomeUnknown
The change may have been applied. Get and check the Service before retrying.
ServiceReasonOther
A reason this SDK does not recognize; RawCode, RawStatus, and RawMessage preserve the refusal.

ChangeState

Every error from CreateService, Update, Enable, Disable, or Remove carries Changed on the base *Error. Use var e *m.Error and errors.As(err, &e) to inspect it.
ChangeUnchanged”unchanged”
Nothing changed.
ChangeUnknown”unknown”
The change may have been applied. Get and check the Service before retrying.