service

package
v0.1.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Function

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

Function defines a generic function type with a single type parameter, IN. This function type takes a context (ctx) and an input of type IN, then returns an error. It is useful for operations where only an error status needs to be returned, and the use of context facilitates proper resource management in asynchronous workflows.

func Wrap

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

Wrap takes a simple function `fn` and converts it into a context-aware `Function`. It ensures the function respects context cancellation or timeout.

type Function2 added in v0.1.4

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

Function2 defines a generic function type with two type parameters, IN and OUT. This function type takes a context (ctx) and an input of type IN, then returns an output of type OUT along with an error. The use of context ensures "cloud native" capabilities by supporting request-scoped values, deadlines, and cancellation signals, which are critical for resource-efficient and robust distributed systems.

func Wrap2 added in v0.1.4

func Wrap2[IN, OUT any](fn func(in IN) (out OUT, err error)) Function2[IN, OUT]

Wrap2 converts a function `fn` into a context-aware `Function2`. It supports cancellation and timeout via the provided context.

Jump to

Keyboard shortcuts

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