usecases

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker struct {
	// Events is a channel of type uuid.UUID that is used to send UUIDs to the goroutine that sends status updates.
	// The channel has a buffer size of 64.
	Events chan uuid.UUID
	// contains filtered or unexported fields
}

Checker represents a struct that handles the logic for sending status updates to the state service.

The Checker struct has the following fields: - Events: A channel of type uuid.UUID that is used to send UUIDs to the goroutine that sends status updates. - state: A StateManager interface that is used to send status updates to the state service.

func NewChecker

func NewChecker(client StateManager) *Checker

NewChecker creates a new instance of the Checker struct.

It takes a StateManager interface as a parameter and returns a pointer to a Checker struct. The Checker struct is used to handle the logic for sending status updates to the state service. It initializes the Events channel with a buffer size of 64, which is used to send UUIDs to the goroutine that sends status updates.

Parameters:

  • client: A StateManager interface used to send events to the state service.

Returns:

  • A pointer to a Checker struct.

func (*Checker) Close

func (c *Checker) Close()

Close closes the Events channel of the Checker.

func (*Checker) Handler

func (c *Checker) Handler(ctx context.Context)

Handler is a goroutine that processes events from the Events channel.

This function continuously listens for events on the Events channel. When an event is received, it sends a status update to the state service. If the context is canceled, the function returns.

Parameters: - ctx: The context.Context object that is used to cancel the goroutine.

func (*Checker) Send

func (c *Checker) Send(id uuid.UUID)

Send sends an event to the events channel of the Checker.

This function sends an event to the events channel of the Checker, which is used to trigger the handler function to process the event.

Parameters:

  • id: The uuid.UUID object representing the event to be sent.

type StateManager

type StateManager interface {
	// Send sends a status update to the state service for a given UUID.
	//
	// Parameters:
	//   - ctx: The context.Context used to cancel the operation if needed.
	//   - id: The UUID of the service.
	//   - status: The entities.Status to send.
	//
	// Returns:
	//   - An error if the status update cannot be sent to the state service,
	//     or nil if the status update was sent successfully.
	Send(ctx context.Context, id uuid.UUID, status entities.Status) error
}

StateManager is an interface that defines the behavior for sending status updates to a state service.

This interface has a single method: - Send: sends a status update for a given UUID.

The Send method has the following parameters: - ctx: a context.Context used to cancel the operation if needed. - id: a UUID representing the ID of the service. - status: a entities.Status representing the status to send.

The Send method returns an error if the status update cannot be sent to the state service, and nil if the status update was sent successfully.

The Send method is used to send a status update for a given UUID to the state service. It takes a context.Context used to cancel the operation if needed, a UUID representing the ID of the service, and a entities.Status representing the status to send. It returns an error if the status update cannot be sent to the state service, and nil if the status update was sent successfully.

Jump to

Keyboard shortcuts

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