producer

package
v0.0.0-...-c606b97 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricsForProducer

type MetricsForProducer interface {
	TotalProducedInc()
}

MetricsForProducer provides a method to increase total produced counter

type Producer

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

func New

func New(
	log *slog.Logger,
	taskSaver TaskSaver,
	taskPublisher TaskPublisher,
	stateProvider StateProvider,
	metrics MetricsForProducer,
) *Producer

func (*Producer) Produce

func (producer *Producer) Produce(ctx context.Context) (int, error)

type StateProvider

type StateProvider interface {
	State(ctx context.Context, id int) (string, error)
}

StateProvider returns task state for a provided task id

type TaskPublisher

type TaskPublisher interface {
	Publish(ctx context.Context, taskId int, taskType int, taskValue int) error
}

TaskPublisher publishes a message with taskId, taskType and taskValue

type TaskSaver

type TaskSaver interface {
	SaveTask(ctx context.Context, taskType int, taskValue int) (int, error)
}

TaskSaver creates a task record with provided task type and task value, returns id

Jump to

Keyboard shortcuts

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