service

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package service enhances service orchestration by grouping related functionality, wrapping functions to support context-aware execution and add lifecycle-oriented functionality like signal handling in cloud-native environments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Context added in v0.1.20

func Context() (ctx context.Context, cancel context.CancelFunc)

Context creates a new context with a cancel function that listens for SIGTERM, SIGINT, SIGQUIT, and SIGKILL signals.

func RegisterOnContextDone added in v0.1.20

func RegisterOnContextDone(ctx context.Context, fn func())

RegisterOnContextDone waits for the context to be done and then calls the function.

Types

type Function

type Function[IN, OUT any] func(ctx context.Context, in IN) (out OUT, err error)

Function gathers together things that change for the same reasons. A context must be handled to be "cloud native" because it allows propagation of deadlines, cancellation signals, and other request-scoped values across API boundaries and between processes. This ensures efficient resource utilization and proper handling of asynchronous workflows in distributed systems.

func Wrap

func Wrap[IN, OUT any](fn func(in IN) (out OUT, err error)) Function[IN, OUT]

Wrap converts a simple function into one that respects a provided context. This enables the wrapped function to respond to context cancellation or timeout.

Jump to

Keyboard shortcuts

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