Documentation
¶
Index ¶
- Variables
- func NewRestartActionError(restartPageToken, reason string) error
- func RestartActionFromError(err error) (*v2.RestartAction, bool)
- func SurfaceRestartAction(err error) error
- type Bag
- func (pb *Bag) Current() *PageState
- func (pb *Bag) Marshal() (string, error)
- func (pb *Bag) Next(pageToken string) error
- func (pb *Bag) NextToken(pageToken string) (string, error)
- func (pb *Bag) PageToken() string
- func (pb *Bag) Pop() *PageState
- func (pb *Bag) Push(state PageState)
- func (pb *Bag) ResourceID() string
- func (pb *Bag) ResourceTypeID() string
- func (pb *Bag) Unmarshal(input string) error
- type GenBag
- type PageState
- type RestartActionError
- type StreamState
- type StreamToken
- type Token
Constants ¶
This section is empty.
Variables ¶
var ErrNoToken = fmt.Errorf("pagination token cannot be nil")
Functions ¶
func NewRestartActionError ¶ added in v0.42.6
NewRestartActionError builds the error a connector returns when the provider rejected the request's page token. An empty restartPageToken restarts the action from its first page.
func RestartActionFromError ¶ added in v0.42.6
func RestartActionFromError(err error) (*v2.RestartAction, bool)
RestartActionFromError returns the detail when the first status in err's chain carries an RestartAction, which is what a gRPC server serializes from the same error. It does not check the status code; the caller decides which codes honor the detail.
func SurfaceRestartAction ¶ added in v0.42.7
SurfaceRestartAction returns err unchanged unless it wraps a RestartActionError that RestartActionFromError does not see because another status error comes first in the chain. Then it returns an error whose status is FailedPrecondition with the RestartAction detail and err's full message, wrapping err. Call it where a connector's error becomes a gRPC status; connectorbuilder's list handlers do.
Types ¶
type Bag ¶
type Bag struct {
// contains filtered or unexported fields
}
Bag holds pagination states that can be serialized for use as page tokens. It acts as a stack that you can push and pop pagination operations from.
func (*Bag) NextToken ¶
Next pops the current token, and pushes a copy of it with an updated page token.
func (*Bag) ResourceID ¶
ResourceID returns the resource ID for the current state.
func (*Bag) ResourceTypeID ¶
ResourceTypeID returns the resource type id for the current state.
type GenBag ¶ added in v0.2.64
type GenBag[T any] struct { // contains filtered or unexported fields }
GenBag holds pagination states that can be serialized for use as page tokens. It acts as a stack that you can push and pop pagination operations from. This is a generic version of the Bag struct.
func GenBagFromToken ¶ added in v0.2.64
func (*GenBag[T]) Current ¶ added in v0.2.64
func (pb *GenBag[T]) Current() *T
Current returns the current page state for the bag.
func (*GenBag[T]) Pop ¶ added in v0.2.64
func (pb *GenBag[T]) Pop() *T
Pop returns the current page action, and makes the top of the stack the current.
type RestartActionError ¶ added in v0.42.6
RestartActionError is returned by a paginated list method when the request's page token can no longer be used. The syncer restarts the action at RestartPageToken; see v2.RestartAction.
The restart is honored only when the error comes straight from the action's own list call (ListResourceTypes, or ListResources, ListEntitlements, ListGrants, ListStaticEntitlements for a resource type) with code FailedPrecondition or Aborted. Returned from any other call (GetResource, a spawned cursor), or under another code, it fails the sync with ErrRestartRejected. A legacy sqlite c1z passes it through unchanged.
A connector built with connectorbuilder may return it bare, wrapped with %w, or behind another status error (uhttp.WrapErrors, errors.Join with a status error): the builder's list handlers call SurfaceRestartAction, so the restart wins over the outer code. A hand-rolled gRPC server must call SurfaceRestartAction itself or return the error bare, because gRPC serializes the first status in the chain and drops the rest.
func (*RestartActionError) Error ¶ added in v0.42.6
func (e *RestartActionError) Error() string
func (*RestartActionError) GRPCStatus ¶ added in v0.42.6
func (e *RestartActionError) GRPCStatus() *status.Status
GRPCStatus carries the detail across the connector gRPC boundary, which flattens handler errors to a status.