Documentation
¶
Overview ¶
Package webhookqueue adapts bounded delivery requests to queue messages.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidConfig = errors.New("webhook/queue: invalid configuration")
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter enqueues versioned delivery requests.
func (*Adapter) Enqueue ¶
Enqueue checks cancellation, encodes a bounded request, and synchronously hands it to queue. Acceptance is not an exactly-once guarantee.
Example ¶
package main
import (
"context"
"fmt"
"net/url"
"github.com/faustbrian/go-queue/core"
"github.com/faustbrian/go-queue/job"
webhook "github.com/faustbrian/go-webhook"
"github.com/faustbrian/go-webhook/adapters/queue"
)
func main() {
queue := &fixtureQueue{}
adapter, _ := webhookqueue.New(webhookqueue.Config{Queue: queue, MaxMessageBytes: 4096})
endpoint, _ := url.Parse("https://receiver.example/hooks")
_ = adapter.Enqueue(context.Background(), webhook.DeliveryRequest{
Endpoint: endpoint, Body: []byte(`{"order":123}`),
EventID: "event-123", IdempotencyKey: "event-123",
})
delivery, _ := webhook.UnmarshalDeliveryRequest(queue.message.Bytes(), 4096)
fmt.Println(delivery.EventID, string(delivery.Body))
}
type fixtureQueue struct {
message core.QueuedMessage
}
func (q *fixtureQueue) Queue(message core.QueuedMessage, _ ...job.AllowOption) error {
q.message = message
return nil
}
Output: event-123 {"order":123}
type Config ¶
type Config struct {
Queue Queue
MaxMessageBytes int
JobOptions []job.AllowOption
}
Config bounds messages and optionally assigns queue-level retry policy. Delivery handling always performs one HTTP attempt, preventing nested retry multiplication.
type Queue ¶
type Queue interface {
Queue(message core.QueuedMessage, options ...job.AllowOption) error
}
Queue is the narrow synchronous producer surface implemented by queue.
Click to show internal directories.
Click to hide internal directories.