cloudflare-log-collector

lifecycle

import "github.com/afreidah/cloudflare-log-collector/internal/lifecycle"

Index

type Manager

Manager registers and supervises background services.

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

func NewManager

func NewManager() *Manager

NewManager creates an empty service manager.

func (*Manager) Register

func (m *Manager) Register(name string, svc Service)

Register adds a named service. Services start in registration order and stop in reverse order.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run starts all registered services and blocks until ctx is cancelled. Each service runs in its own goroutine with panic recovery and automatic restart.

func (*Manager) Stop

func (m *Manager) Stop(timeout time.Duration)

Stop calls Stop on services that implement Stoppable, in reverse registration order, bounded by the given timeout.

type Service

Service represents a long-running background task. Run blocks until ctx is cancelled or a fatal error occurs.

type Service interface {
    Run(ctx context.Context) error
}

type Stoppable

Stoppable is an optional interface for services that need explicit cleanup beyond context cancellation.

type Stoppable interface {
    Stop(ctx context.Context) error
}

Generated by gomarkdoc