mono

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: Apache-2.0 Imports: 7 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mono

type Mono interface {
	rx.Publisher
	// Filter evaluate each source value against the given Predicate.
	// If the predicate test succeeds, the value is emitted.
	Filter(rx.FnPredicate) Mono
	// Map transform the item emitted by this Mono by applying a synchronous function to another.
	Map(rx.FnTransform) Mono
	// FlatMap Transform the item emitted by this Mono asynchronously, returning the value emitted by another Mono.
	FlatMap(func(payload.Payload) Mono) Mono
	// DoFinally adds behavior (side-effect) triggered after the Mono terminates for any reason, including cancellation.
	DoFinally(rx.FnFinally) Mono
	// DoOnError adds behavior (side-effect) triggered when the Mono completes with an error.
	DoOnError(rx.FnOnError) Mono
	// DoOnSuccess adds behavior (side-effect) triggered when the Mono completes with an success.
	DoOnSuccess(rx.FnOnNext) Mono
	// DoOnCancel add behavior (side-effect) triggered when the Mono is cancelled.
	DoOnCancel(rx.FnOnCancel) Mono
	// DoOnSubscribe add behavior (side-effect) triggered when the Mono is done being subscribed.
	DoOnSubscribe(rx.FnOnSubscribe) Mono
	// SubscribeOn customize a Scheduler running Subscribe, OnSubscribe and Request.
	SubscribeOn(scheduler.Scheduler) Mono
	// SubscribeWithChan subscribe to this Mono and puts item/error into channels.
	SubscribeWithChan(ctx context.Context, valueChan chan<- payload.Payload, errChan chan<- error)
	// Block blocks Mono and returns data and error.
	Block(context.Context) (payload.Payload, error)
	//SwitchIfEmpty switch to an alternative Publisher if this Mono is completed without any data.
	SwitchIfEmpty(alternative Mono) Mono
	// Raw returns low-level reactor.Mono which defined in reactor-go library.
	Raw() mono.Mono
	// ToChan subscribe Mono and puts items into a chan.
	// It also puts errors into another chan.
	ToChan(ctx context.Context) (c <-chan payload.Payload, e <-chan error)
}

Mono is a Reactive Streams Publisher with basic rx operators that completes successfully by emitting an element, or with an error.

func Create

func Create(gen func(context.Context, Sink)) Mono

Create wrap a generator function to a Mono.

func CreateFromChannel added in v0.3.1

func CreateFromChannel(payloads <-chan payload.Payload, err <-chan error) Mono

CreateFromChannel creates a Mono from channels.

func Empty

func Empty() Mono

Empty returns an empty Mono.

func Error added in v0.3.1

func Error(err error) Mono

Error wrap an error to a Mono.

func Just

func Just(input payload.Payload) Mono

Just wrap an exist Payload to a Mono.

func JustOrEmpty

func JustOrEmpty(input payload.Payload) Mono

JustOrEmpty wrap an exist Payload to Mono. Payload could be nil here.

func Raw

func Raw(input mono.Mono) Mono

Raw wrap a low-level Mono.

type Processor

type Processor interface {
	Sink
	Mono
}

Processor combine Sink and Mono.

func CreateProcessor

func CreateProcessor() Processor

CreateProcessor creates a Processor.

type Sink

type Sink interface {
	// Success emits a single value then complete current Sink.
	Success(payload.Payload)
	// Error emits an error then complete current Sink.
	Error(error)
}

Sink is a wrapper API around an actual downstream Subscriber for emitting nothing, a single value or an error (mutually exclusive).

Jump to

Keyboard shortcuts

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