chantools

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 7 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Broadcast

func Broadcast[T any](src <-chan T, qty uint) []<-chan T

func BroadcastSync

func BroadcastSync[T any](src <-chan T, qty uint) []<-chan T

func CastTo

func CastTo[T any](ch <-chan any) <-chan T

func CastToAny

func CastToAny[T any](ch <-chan T) <-chan any

func CastToReader

func CastToReader[T any](ch ...chan T) []<-chan T

func Concat added in v0.0.4

func Concat[E any, C <-chan E](inputs ...C) []E

func Flatten added in v0.0.3

func Flatten[I any](input <-chan []I) <-chan I

func ForEach

func ForEach[T any](src <-chan T, each func(element T))

func ForwardIf

func ForwardIf[T any](src <-chan T, where func(element T) bool, option ...NewChanOptions[T]) <-chan T

func ForwardTo

func ForwardTo[T any](ctx context.Context, src <-chan T, dst chan<- T)

func MakeSliceChan

func MakeSliceChan[T any](qty uint) []chan T

func Map added in v0.0.3

func Map[I any, O any](input <-chan I, mapper func(input I) O, option ...NewChanOptions[O]) <-chan O

func MapSlice

func MapSlice[I any, IA ~[]I, O any](input IA, mapper func(input I) O) []O

func Merge added in v0.0.2

func Merge[E any, C <-chan E](inputs ...C) C

func New added in v0.0.2

func New[C any](worker func(c chan<- C, params ...any), option ...NewChanOptions[C]) <-chan C

func NewSync added in v0.0.4

func NewSync[C any](worker func(c chan<- C, params ...any), option ...NewChanOptions[C]) []C

func NewSyncWithErr added in v0.0.4

func NewSyncWithErr[C any](worker func(c chan<- C, eC chan<- error, params ...any), option ...NewChanOptions[C]) ([]C, []error)

func NewWithErr added in v0.0.2

func NewWithErr[C any](worker func(c chan<- C, eC chan<- error, params ...any), option ...NewChanOptions[C]) (<-chan C, <-chan error)

func NewWriter added in v0.0.2

func NewWriter(c chan<- []byte) io.WriteCloser

NewWriter

func Once added in v0.0.2

func Once[C any](value C) <-chan C

func Tick

func Tick[I any](ctx context.Context, interval time.Duration, generate func() (I, error)) (<-chan I, <-chan error)

Types

type BrokerChan

type BrokerChan[E any] struct {
	// contains filtered or unexported fields
}

func NewBrokerChan

func NewBrokerChan[E any](src <-chan E) *BrokerChan[E]

func (*BrokerChan[E]) Subscribe

func (bc *BrokerChan[E]) Subscribe() <-chan E

type ChanWriter added in v0.0.2

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

ChanWriter is really naive implementation of io.Writer to channel

func (*ChanWriter) Close added in v0.0.2

func (cw *ChanWriter) Close() error

func (*ChanWriter) Write added in v0.0.2

func (cw *ChanWriter) Write(data []byte) (int, error)

type ForwardToExtensions

type ForwardToExtensions[I any] func(c I) error

type ListenProperty

type ListenProperty[E any] struct {
	// contains filtered or unexported fields
}

func Listen

func Listen[E any](initialProperty E) *ListenProperty[E]

func ListenChan

func ListenChan[E any](ctx context.Context, initialProperty E, src <-chan E) *ListenProperty[E]

func ListenWithContext

func ListenWithContext[E any](ctx context.Context, initialProperty E) *ListenProperty[E]

func (ListenProperty[E]) Close

func (lp ListenProperty[E]) Close()

func (*ListenProperty[E]) Forward

func (lp *ListenProperty[E]) Forward(ctx context.Context, i <-chan E)

func (*ListenProperty[E]) Set

func (lp *ListenProperty[E]) Set(value E)

func (ListenProperty[E]) Updates

func (lp ListenProperty[E]) Updates() <-chan E

func (ListenProperty[E]) Value

func (lp ListenProperty[E]) Value() E

type NewChanOptions added in v0.0.2

type NewChanOptions[I any] func(ct *chanToolsConfig[I])

func WithBuffer added in v0.0.2

func WithBuffer[I any](count int64) NewChanOptions[I]

func WithContext added in v0.0.3

func WithContext[I any](ctx context.Context) NewChanOptions[I]

WithCOntext option will prevent the go routine to finish until the context.Done() chan return a result

func WithInitialValue

func WithInitialValue[I any](initialValue I) NewChanOptions[I]

func WithLastValue added in v0.0.2

func WithLastValue[I any](lasValue I) NewChanOptions[I]

func WithName added in v0.0.3

func WithName[I any](name string) NewChanOptions[I]

func WithNonBlocking added in v0.0.2

func WithNonBlocking[I any]() NewChanOptions[I]

func WithNonManagedChannel added in v0.0.3

func WithNonManagedChannel[I any]() NewChanOptions[I]

func WithParam added in v0.0.2

func WithParam[I any](p ...any) NewChanOptions[I]

Jump to

Keyboard shortcuts

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