Documentation
¶
Index ¶
- Constants
- Variables
- type APIError
- type BatchResultWire
- type ConfigProvider
- type CreateQueueIn
- type GetMessageWire
- type GetParams
- type Handler
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- func (h *Handler) Trusted() echo.HandlerFunc
- type InMemoryBackend
- func (b *InMemoryBackend) ChangeQueueCompartment(id, ifMatch, compartment string) (string, error)
- func (b *InMemoryBackend) Compartments() []string
- func (b *InMemoryBackend) CreateQueue(in CreateQueueIn) (string, error)
- func (b *InMemoryBackend) DeleteMessage(queueID, receipt string) error
- func (b *InMemoryBackend) DeleteMessages(queueID string, in receiptsIn) (BatchResultWire, error)
- func (b *InMemoryBackend) DeleteQueue(id, ifMatch string) (string, error)
- func (b *InMemoryBackend) GetMessages(ctx context.Context, stop <-chan struct{}, queueID string, p GetParams) ([]GetMessageWire, error)
- func (b *InMemoryBackend) GetQueue(id, endpoint string) (QueueWire, string, error)
- func (b *InMemoryBackend) GetStats(queueID, channel string) (QueueStatsWire, error)
- func (b *InMemoryBackend) GetWorkRequest(id string) (WorkRequestWire, error)
- func (b *InMemoryBackend) ListChannels(queueID, filter string, o ListOpts) (page.Page[string], error)
- func (b *InMemoryBackend) ListQueues(compartment, id, name, state, endpoint string, o ListOpts) (page.Page[queueSummaryWire], error)
- func (b *InMemoryBackend) ListWorkRequests(compartment, resourceID, id string, o ListOpts) (page.Page[WorkRequestWire], error)
- func (b *InMemoryBackend) Peek(queueID string, dlq bool, limit int) ([]PeekedMessage, error)
- func (b *InMemoryBackend) PurgeQueue(id, ifMatch string, in PurgeIn) (string, error)
- func (b *InMemoryBackend) PutMessages(queueID string, in putMessagesIn) ([]PutMessageWire, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) SetKeyChecker(fn KeyChecker)
- func (b *InMemoryBackend) SetTimer(after func(time.Duration) <-chan time.Time)
- func (b *InMemoryBackend) SetTransition(d time.Duration)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) Sweep()
- func (b *InMemoryBackend) UpdateMessage(queueID, receipt string, vis *int) (UpdatedWire, error)
- func (b *InMemoryBackend) UpdateMessages(queueID string, in receiptsIn) (BatchResultWire, error)
- func (b *InMemoryBackend) UpdateQueue(id, ifMatch string, in UpdateQueueIn) (string, error)
- func (b *InMemoryBackend) WorkRequestExists(id string) error
- func (b *InMemoryBackend) WorkRequestLogs(id string, o ListOpts) (page.Page[wrLogWire], error)
- type KeyChecker
- type ListOpts
- type Message
- type PeekedMessage
- type Provider
- type PurgeIn
- type PutMessageWire
- type Queue
- type QueueStatsWire
- type QueueWire
- type Settings
- type Tags
- type UpdateQueueIn
- type UpdatedWire
- type WorkRequest
- type WorkRequestWire
Constants ¶
const DefaultPort = 8156
DefaultPort is the dedicated listener's default TCP port.
const (
// Region is the fixed region baked into emulated OCIDs.
Region = "us-ashburn-1"
)
Variables ¶
var ErrNilAppContext = errors.New("ociqueue: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
var ErrSnapshotNull = errors.New("ociqueue: null entry in snapshot")
ErrSnapshotNull is returned when a snapshot contains a null entry.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is an OCI error response: HTTP status plus the `code` and `message` body fields.
type BatchResultWire ¶
type ConfigProvider ¶
type ConfigProvider interface {
GetOCIQueueSettings() Settings
}
ConfigProvider extracts OCI Queue configuration from the AppContext Config.
type CreateQueueIn ¶
type CreateQueueIn struct {
Tags
Retention *int `json:"retentionInSeconds"`
Visibility *int `json:"visibilityInSeconds"`
Timeout *int `json:"timeoutInSeconds"`
ChannelLimit *int `json:"channelConsumptionLimit"`
DLQCount *int `json:"deadLetterQueueDeliveryCount"`
KMSKeyID *string `json:"customEncryptionKeyId"`
Name string `json:"displayName"`
Compartment string `json:"compartmentId"`
Capabilities []json.RawMessage `json:"capabilities"`
}
CreateQueueIn is the CreateQueue request body.
type GetMessageWire ¶
type GetMessageWire struct {
VisibleAfter time.Time `json:"visibleAfter"`
ExpireAfter time.Time `json:"expireAfter"`
CreatedAt time.Time `json:"createdAt"`
Metadata *metaWire `json:"metadata,omitempty"`
Content string `json:"content"`
Receipt string `json:"receipt"`
ID int64 `json:"id"`
DeliveryCount int `json:"deliveryCount"`
}
type GetParams ¶
GetParams carries the GetMessages query parameters; nil fields fall back to the queue defaults.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
Port int
EnforceAuth bool
// contains filtered or unexported fields
}
Handler serves OCI Queue: queue administration and the messages API.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Handler; callers override Port and EnforceAuth from Settings.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name for metrics.
func (*Handler) ExtractResource ¶
ExtractResource returns the addressed resource id for metrics.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the supported operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler for all OCIQueue requests.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: OCIQueue runs on its own listener.
func (*Handler) Snapshot ¶
Snapshot implements persistence.Persistable by delegating to the backend.
func (*Handler) StartWorker ¶
StartWorker binds the dedicated listener synchronously so a port conflict is returned to the caller.
func (*Handler) Trusted ¶
func (h *Handler) Trusted() echo.HandlerFunc
Trusted returns a handler that skips request-signature verification, for the in-process dashboard proxy.
type InMemoryBackend ¶
InMemoryBackend holds every queue and work request under one lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) ChangeQueueCompartment ¶
func (b *InMemoryBackend) ChangeQueueCompartment(id, ifMatch, compartment string) (string, error)
ChangeQueueCompartment moves a queue to another compartment.
func (*InMemoryBackend) Compartments ¶
func (b *InMemoryBackend) Compartments() []string
Compartments lists the distinct compartments that hold live queues.
func (*InMemoryBackend) CreateQueue ¶
func (b *InMemoryBackend) CreateQueue(in CreateQueueIn) (string, error)
CreateQueue creates a queue in CREATING state and returns its work request.
func (*InMemoryBackend) DeleteMessage ¶
func (b *InMemoryBackend) DeleteMessage(queueID, receipt string) error
DeleteMessage deletes one message by receipt.
func (*InMemoryBackend) DeleteMessages ¶
func (b *InMemoryBackend) DeleteMessages(queueID string, in receiptsIn) (BatchResultWire, error)
DeleteMessages deletes several messages by receipt; each entry reports its own result.
func (*InMemoryBackend) DeleteQueue ¶
func (b *InMemoryBackend) DeleteQueue(id, ifMatch string) (string, error)
DeleteQueue moves a queue to DELETING.
func (*InMemoryBackend) GetMessages ¶
func (b *InMemoryBackend) GetMessages( ctx context.Context, stop <-chan struct{}, queueID string, p GetParams, ) ([]GetMessageWire, error)
GetMessages returns visible messages, long polling until one arrives, timeout elapses, ctx or stop ends.
func (*InMemoryBackend) GetQueue ¶
func (b *InMemoryBackend) GetQueue(id, endpoint string) (QueueWire, string, error)
GetQueue returns one queue and its etag.
func (*InMemoryBackend) GetStats ¶
func (b *InMemoryBackend) GetStats(queueID, channel string) (QueueStatsWire, error)
GetStats counts visible and in-flight messages and their size, for the queue and its dead letter queue.
func (*InMemoryBackend) GetWorkRequest ¶
func (b *InMemoryBackend) GetWorkRequest(id string) (WorkRequestWire, error)
GetWorkRequest returns one work request.
func (*InMemoryBackend) ListChannels ¶
func (b *InMemoryBackend) ListChannels(queueID, filter string, o ListOpts) (page.Page[string], error)
ListChannels lists the channels that currently hold messages.
func (*InMemoryBackend) ListQueues ¶
func (b *InMemoryBackend) ListQueues( compartment, id, name, state, endpoint string, o ListOpts, ) (page.Page[queueSummaryWire], error)
ListQueues lists the queues of a compartment.
func (*InMemoryBackend) ListWorkRequests ¶
func (b *InMemoryBackend) ListWorkRequests( compartment, resourceID, id string, o ListOpts, ) (page.Page[WorkRequestWire], error)
ListWorkRequests lists the work requests of a compartment, optionally for one resource.
func (*InMemoryBackend) Peek ¶
func (b *InMemoryBackend) Peek(queueID string, dlq bool, limit int) ([]PeekedMessage, error)
Peek returns up to limit messages of a queue or its dead letter queue without delivering them: no receipt is issued, delivery counts and visibility stay untouched.
func (*InMemoryBackend) PurgeQueue ¶
func (b *InMemoryBackend) PurgeQueue(id, ifMatch string, in PurgeIn) (string, error)
PurgeQueue deletes the messages of a queue, its dead letter queue, or both, optionally per channel.
func (*InMemoryBackend) PutMessages ¶
func (b *InMemoryBackend) PutMessages(queueID string, in putMessagesIn) ([]PutMessageWire, error)
PutMessages appends messages to a queue.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a snapshot.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time)
SetClock injects the time source used for lifecycle, visibility and retention.
func (*InMemoryBackend) SetKeyChecker ¶
func (b *InMemoryBackend) SetKeyChecker(fn KeyChecker)
SetKeyChecker wires validation of customEncryptionKeyId references against a Vault backend.
func (*InMemoryBackend) SetTimer ¶
func (b *InMemoryBackend) SetTimer(after func(time.Duration) <-chan time.Time)
SetTimer injects the wait used by long polls; it must return a channel that fires after d.
func (*InMemoryBackend) SetTransition ¶
func (b *InMemoryBackend) SetTransition(d time.Duration)
SetTransition sets how long CREATING, UPDATING and DELETING states last.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state, including registered API keys.
func (*InMemoryBackend) Sweep ¶
func (b *InMemoryBackend) Sweep()
Sweep applies lifecycle transitions, retention and dead lettering against the backend clock.
func (*InMemoryBackend) UpdateMessage ¶
func (b *InMemoryBackend) UpdateMessage(queueID, receipt string, vis *int) (UpdatedWire, error)
UpdateMessage changes the visibility of one in-flight message.
func (*InMemoryBackend) UpdateMessages ¶
func (b *InMemoryBackend) UpdateMessages(queueID string, in receiptsIn) (BatchResultWire, error)
UpdateMessages changes the visibility of several in-flight messages; each entry reports its own result.
func (*InMemoryBackend) UpdateQueue ¶
func (b *InMemoryBackend) UpdateQueue(id, ifMatch string, in UpdateQueueIn) (string, error)
UpdateQueue changes the mutable settings of a queue; it passes through UPDATING.
func (*InMemoryBackend) WorkRequestExists ¶
func (b *InMemoryBackend) WorkRequestExists(id string) error
WorkRequestExists reports whether a work request exists (its error list is always empty).
func (*InMemoryBackend) WorkRequestLogs ¶
WorkRequestLogs returns the log entries of a work request.
type KeyChecker ¶
KeyChecker reports the lifecycle state of a KMS key OCID and whether it exists.
type Message ¶
type Message struct {
Created time.Time `json:"created"`
Expire time.Time `json:"expire"`
VisibleAfter time.Time `json:"visibleAfter"`
Props map[string]string `json:"props,omitempty"`
Content string `json:"content"`
Channel string `json:"channel,omitempty"`
Receipt string `json:"receipt,omitempty"`
ID int64 `json:"id"`
Deliveries int `json:"deliveries"`
}
Message is one stored queue message.
type PeekedMessage ¶
type PeekedMessage struct {
CreatedAt time.Time `json:"createdAt"`
VisibleAfter time.Time `json:"visibleAfter"`
ExpireAfter time.Time `json:"expireAfter"`
Properties map[string]string `json:"customProperties,omitempty"`
Content string `json:"content"`
Channel string `json:"channelId,omitempty"`
ID int64 `json:"id"`
DeliveryCount int `json:"deliveryCount"`
InFlight bool `json:"inFlight"`
}
PeekedMessage is a read-only view of one stored message; it carries no receipt.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for OCI Queue. It runs on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the port is bound in StartWorker.
type PurgeIn ¶
type PurgeIn struct {
ConsumerGroupID *string `json:"consumerGroupId"`
PurgeType string `json:"purgeType"`
ChannelIDs []string `json:"channelIds"`
}
PurgeIn is the PurgeQueue request body.
type PutMessageWire ¶
type Queue ¶
type Queue struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
TransitionAt *time.Time `json:"transitionAt,omitempty"`
Tags Tags `json:"tags"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
Name string `json:"name"`
State string `json:"state"`
KMSKeyID string `json:"kmsKeyId,omitempty"`
Etag string `json:"etag"`
Messages []*Message `json:"messages,omitempty"`
DLQ []*Message `json:"dlq,omitempty"`
Retention int `json:"retentionInSeconds"`
Visibility int `json:"visibilityInSeconds"`
Timeout int `json:"timeoutInSeconds"`
DLQCount int `json:"deadLetterQueueDeliveryCount"`
ChannelLimit int `json:"channelConsumptionLimit"`
NextMsgID int64 `json:"nextMsgId"`
Seq int64 `json:"seq"`
// contains filtered or unexported fields
}
Queue is a message queue with its dead letter queue.
type QueueStatsWire ¶
type QueueStatsWire struct {
Queue statsWire `json:"queue"`
DLQ statsWire `json:"dlq"`
}
type QueueWire ¶
type QueueWire struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
FreeformTags map[string]string `json:"freeformTags,omitempty"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
KMSKeyID *string `json:"customEncryptionKeyId,omitempty"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
Name string `json:"displayName"`
LifecycleState string `json:"lifecycleState"`
MessagesEndpoint string `json:"messagesEndpoint"`
Retention int `json:"retentionInSeconds"`
Visibility int `json:"visibilityInSeconds"`
Timeout int `json:"timeoutInSeconds"`
DLQCount int `json:"deadLetterQueueDeliveryCount"`
ChannelLimit int `json:"channelConsumptionLimit"`
}
type Settings ¶
type Settings struct {
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 205-byte string literal not displayed */
EnforceAuth bool `` //nolint:lll // config struct tags are intentionally verbose
/* 221-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI as CLI.OCIQueue.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.
type Tags ¶
type Tags struct {
FreeformTags map[string]string `json:"freeformTags,omitempty"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
}
Tags are the shared freeform and defined tag sets of a resource.
type UpdateQueueIn ¶
type UpdateQueueIn struct {
Tags
Name *string `json:"displayName"`
Visibility *int `json:"visibilityInSeconds"`
Timeout *int `json:"timeoutInSeconds"`
ChannelLimit *int `json:"channelConsumptionLimit"`
DLQCount *int `json:"deadLetterQueueDeliveryCount"`
KMSKeyID *string `json:"customEncryptionKeyId"`
Capabilities []json.RawMessage `json:"capabilities"`
}
UpdateQueueIn is the UpdateQueue request body.
type UpdatedWire ¶
type WorkRequest ¶
type WorkRequest struct {
Accepted time.Time `json:"accepted"`
FinishAt time.Time `json:"finishAt"`
ID string `json:"id"`
Operation string `json:"operation"`
CompartmentID string `json:"compartmentId"`
EntityType string `json:"entityType"`
EntityID string `json:"entityId"`
EntityURI string `json:"entityUri"`
Action string `json:"action"`
Seq int64 `json:"seq"`
}
WorkRequest records an asynchronous admin operation.
type WorkRequestWire ¶
type WorkRequestWire struct {
TimeAccepted time.Time `json:"timeAccepted"`
TimeStarted *time.Time `json:"timeStarted,omitempty"`
TimeFinished *time.Time `json:"timeFinished,omitempty"`
OperationType string `json:"operationType"`
Status string `json:"status"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
Resources []wrResourceWire `json:"resources"`
PercentComplete float32 `json:"percentComplete"`
}