form

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(path string, msg hermod.Message) error

Dispatch sends a message to the channel registered for the given path.

func Register

func Register(path string) chan hermod.Message

Register creates a new channel for a form path, superseding any existing registration. The newest registration owns the path: when a workflow moves between workers, the one taking the lease over is the one that should receive.

It used to return the existing channel instead, which meant the worker taking over and the worker being replaced read from the same one — so the outgoing teardown closed the channel its successor was reading.

func Unregister

func Unregister(path string, ch chan hermod.Message)

Unregister releases a path, but only if ch is still the channel registered for it.

The ownership check is what makes a handover safe. Nothing orders the outgoing worker's teardown against the incoming worker's registration, so deleting by path alone let a worker that had already lost the lease close and remove its successor's channel. The successor was then reading from a closed channel that no longer appeared in the registry: the workflow reported itself running and never received another message.

Types

type FormSource

type FormSource struct {
	Path    string
	Storage Storage
	// contains filtered or unexported fields
}

FormSource implements the hermod.Source interface for receiving form submissions.

func NewFormSource

func NewFormSource(path string, storage Storage) *FormSource

NewFormSource creates a new FormSource.

func (*FormSource) Ack

func (s *FormSource) Ack(ctx context.Context, msg hermod.Message) error

func (*FormSource) Close

func (s *FormSource) Close() error

func (*FormSource) Ping

func (s *FormSource) Ping(ctx context.Context) error

func (*FormSource) Read

func (s *FormSource) Read(ctx context.Context) (hermod.Message, error)

func (*FormSource) Sample

func (s *FormSource) Sample(ctx context.Context, table string) (hermod.Message, error)

type FormSubmission

type FormSubmission struct {
	ID        string
	Timestamp time.Time
	Path      string
	Data      []byte
	Status    string
}

type FormSubmissionFilter

type FormSubmissionFilter struct {
	Path   string
	Status string
	Limit  int
	Page   int
}

type Storage

type Storage interface {
	CreateFormSubmission(ctx context.Context, sub FormSubmission) error
	ListFormSubmissions(ctx context.Context, filter FormSubmissionFilter) ([]FormSubmission, int, error)
	UpdateFormSubmissionStatus(ctx context.Context, id string, status string) error
}

Jump to

Keyboard shortcuts

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