channels

package
v8.42.1698085480-SHA-e... Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package channels provide some simple adapters to facilitate common read/write patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapBetween

func MapBetween[A, B any](src Source[A], dst Sink[B], fn MapFn[A, B]) task.Task

Types

type MapFn

type MapFn[A, B any] func(context.Context, A) (B, error)

type Receiver

type Receiver[T any] func() (T, error)

type Sender

type Sender[T any] func(T) error

type Sink

type Sink[T any] chan<- T

func NewSink

func NewSink[T any](c chan<- T) Sink[T]

NewSink takes a writable channel and returns a Sink, which can be used to chain common transformations fluently.

func (Sink[T]) FillFrom

func (s Sink[T]) FillFrom(recv Receiver[T]) task.Task

type Source

type Source[T any] <-chan T

func NewSource

func NewSource[T any](c <-chan T) Source[T]

NewSource takes a readable channel and returns a Source, which can be used to chain common transformations fluently.

func (Source[T]) ForwardTo

func (s Source[T]) ForwardTo(send Sender[T]) task.Task

Jump to

Keyboard shortcuts

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