Documentation
¶
Overview ¶
Package gateboard provides library for clients.
Recommended Usage ¶
This pseudocode illustrates the recommended usage:
// invokeBackend calls a backend http endpoint for a gateway named 'gatewayName'.
// 'client' is created in an wider scope because it caches IDs.
function invokeBackend(client, gatewayName)
1. get ID := client.GatewayID(gatewayName)
2. if ID is "" {
return status code 503
}
3. call the backend http endpoint with header "x-apigw-api-id: <id>"
if backend status code is 403 {
client.Refresh(gatewayName)
return status code 503
}
4. return backend status code
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BodyGetReply ¶
type BodyGetReply struct {
GatewayName string `json:"gateway_name" yaml:"gateway_name" bson:"gateway_name" dynamodbav:"gateway_name"`
GatewayID string `json:"gateway_id" yaml:"gateway_id" bson:"gateway_id" dynamodbav:"gateway_id"`
Changes int64 `json:"changes" yaml:"changes" bson:"changes" dynamodbav:"changes"`
LastUpdate time.Time `json:"last_update" yaml:"last_update" bson:"last_update" dynamodbav:"last_update"`
Error string `json:"error,omitempty" yaml:"error,omitempty" bson:"error,omitempty" dynamodbav:"error,omitempty"`
TTL int `json:"TTL,omitempty" yaml:"TTL,omitempty" bson:"TTL,omitempty" dynamodbav:"TTL,omitempty"`
Token string `json:"token,omitempty" yaml:"token,omitempty" bson:"token,omitempty" dynamodbav:"token,omitempty"`
}
BodyGetReply defines the payload format for a GET request.
type BodyPutReply ¶
type BodyPutReply struct {
GatewayName string `json:"gateway_name" yaml:"gateway_name"`
GatewayID string `json:"gateway_id" yaml:"gateway_id"`
Error string `json:"error,omitempty" yaml:"error,omitempty"`
}
BodyPutReply defines the payload format for a PUT response.
type BodyPutRequest ¶
type BodyPutRequest struct {
GatewayID string `json:"gateway_id" yaml:"gateway_id"`
Token string `json:"token,omitempty" yaml:"token,omitempty"`
}
BodyPutRequest defines the payload format for a PUT request.
type Client ¶
Client holds context for a gateboard client.
func NewClient ¶
func NewClient(options ClientOptions) *Client
NewClient creates a new gateboard client.
type ClientOptions ¶
type ClientOptions struct {
ServerURL string // required main centralized server
TTLMin time.Duration // optional, if unspecified defaults to CacheTTLMinimum
TTLMax time.Duration // optional, if unspecified defaults to CacheTTLMax
TTLDefault time.Duration // optional, if unspecified defaults to CacheTTLDefault
Debug bool // optional, log debug information
Tracer trace.Tracer
}
ClientOptions defines options for the client.
Click to show internal directories.
Click to hide internal directories.