lifecycle

package
v0.0.0-...-89aa834 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package lifecycle provides interfaces and types for managing the lifecycle of components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseLifecycle

type BaseLifecycle struct{}

BaseLifecycle provides a default implementation of the Lifecycle interface.

func (*BaseLifecycle) Init

Init implements the Init method of the Lifecycle interface.

func (*BaseLifecycle) Shutdown

func (*BaseLifecycle) Shutdown(context.Context) error

Shutdown implements the Shutdown method of the Lifecycle interface.

func (*BaseLifecycle) Start

Start implements the Start method of the Lifecycle interface.

func (*BaseLifecycle) Uninit

Uninit implements the Uninit method of the Lifecycle interface.

type Funcs

type Funcs struct {
	Init     func(context.Context) error
	Start    func(context.Context) error
	Shutdown func(context.Context) error
	Uninit   func(context.Context) error
}

Funcs represents a set of lifecycle functions for a simple component.

type Lifecycle

type Lifecycle interface {
	// Init initializes the component.
	Init(context.Context) error
	// Uninit performs cleanup after the component is no longer needed.
	Uninit(context.Context) error
	// Start begins the component's main operations.
	Start(context.Context) error
	// Shutdown gracefully stops the component's operations.
	Shutdown(context.Context) error
}

Lifecycle defines the interface for components with lifecycle management.

type Status

type Status int

Status represents the lifecycle state of a component.

const (
	// Created indicates that the component has been instantiated but not yet initialized.
	Created Status = iota
	// Starting indicates that the component is in the process of starting.
	Starting
	// Running indicates that the component is fully operational.
	Running
	// Stopping indicates that the component is in the process of shutting down.
	Stopping
	// Closed indicates that the component has been fully shut down.
	Closed
)

func (Status) String

func (s Status) String() string

String returns a string representation of the Status.

Jump to

Keyboard shortcuts

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