Documentation
¶
Overview ¶
Package riverkit composes library workers into one host-owned River client. It does not migrate a database, own a pool, or start or stop the returned client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(ctx context.Context, pool *pgxpool.Pool, options *river.Config, jobs ...Contribution) (client *river.Client[pgx.Tx], err error)
New registers every contribution before constructing one unstarted client, then binds its producers. A failed composition consumes its contributions; discard the participating library runtimes and construct fresh ones. The input config's maps and slices are copied. An existing Workers registry may be extended during registration and must also be discarded on failure.
Types ¶
type Binding ¶ added in v0.2.0
Binding is the final client and the exact pool used to construct it. Both are borrowed from the host: contributions must not start/stop the client or close the pool. A contribution may use Pool to verify its transactional producers address the same physical database before enabling them.
type Contribution ¶
type Contribution struct {
// contains filtered or unexported fields
}
Contribution is one library's startup registration and producer binding. Copies share the same single-use identity. Libraries also guard their own lifecycle so requesting a fresh contribution cannot compose a runtime twice.
func Group ¶
func Group(jobs ...Contribution) Contribution
Group bundles a library's own jobs with already attached components. It does not register or bind anything. Children are flattened before any composition validation, so duplicate registrations cannot hide inside a group.
func NewContribution ¶
func NewContribution(name string, register func(context.Context, *river.Config) error, bind func(context.Context, Binding) error, abort func() error) Contribution
NewContribution describes one library's jobs. register adds workers, active queues and periodic jobs; bind attaches the final unstarted client to any request-side producers. abort must invalidate partial registration/binding and release only the library's composition resources, never the host pool. Construction is side-effect free. Nil bind/abort hooks are allowed for a stateless contribution with no producer or resources to clean up. A bind callback requires an abort callback to invalidate any partial producer binding.