process

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package process is a subpackage of coordinator, providing simple way to create and manage processes such as servers, metrics, and profiling in a clean and controlled manner.

This package allows you to focus on the logic for starting and stopping processes within goroutines, while the coordinator handles the application lifecycle.

To use this package, implement the Process interface, which includes methods to trigger events like OnStart and OnStop, ensuring integration and control over your application's processes via coordinator.ServiceCoordinator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCriticalToStop

func IsCriticalToStop(t Process) bool

IsCriticalToStop checks if the task is essential for execution.

Types

type Process

type Process interface {
	// GetName method returns the name of the task.
	GetName() string
	// GetSeverity method returns the severity/importance of the task.
	GetSeverity() Severity
	// OnStart method is an event to be called when the main loop starts.
	OnStart(ctx context.Context) error
	// OnStop method is an event to be called when the main loop stops.
	OnStop(ctx context.Context) error
}

Process interface represents a task that requires execution within a microservice. This could include a variety of tasks such as servers, events, parsers, aggregators, etc.

type Severity

type Severity byte

Severity is an enumerated type representing the importance of a background task to be executed.

const (
	// TaskSeverityMajor is a constant representing processes critical for execution.
	TaskSeverityMajor Severity = iota
	// TaskSeverityMinor is a constant representing processes classified as non-critical or optional for execution.
	TaskSeverityMinor
)

Jump to

Keyboard shortcuts

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