async

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package async adapts the original Datly .job storage-event transport to the durable jobs service. AFS owns local and cloud URL operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(fs afs.Service, service JobHandler) (*Dispatcher, error)

func (*Dispatcher) DispatchStorageEvent

func (d *Dispatcher) DispatchStorageEvent(ctx context.Context, object afsstorage.Object) (err error)

DispatchStorageEvent accepts the same AFS storage.Object produced by local, S3 or GS adapters. It never opens an HTTP loopback connection.

type JobHandler

type JobHandler interface {
	HandleJob(context.Context, *jobs.Event) (any, error)
}

JobHandler accepts durable events through the existing job service or its application admission owner.

type PublishConfig

type PublishConfig struct {
	FS           afs.Service
	Notification xasync.Notification
}

type Publisher

type Publisher struct {
	// contains filtered or unexported fields
}

func NewPublisher

func NewPublisher(config PublishConfig) (*Publisher, error)

func (*Publisher) Prepare

func (p *Publisher) Prepare(record *jobs.Record) error

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, record *jobs.Record) error

type WatchConfig

type WatchConfig struct {
	JobURL       string
	FailedJobURL string
	MaxJobs      int
	PollInterval time.Duration
	// Error receives dispatch/post-processing failures. Concurrent workers may
	// report concurrently; the sink must be concurrency-safe.
	Error func(string, error)
}

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher(config WatchConfig, dispatcher *Dispatcher) (*Watcher, error)

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context) error

Run joins all owned workers on server-context cancellation. MaxJobs=0 retains original unlimited admission; a positive value is scoped to this watcher.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL