union

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 6 Imported by: 0

README

GoDoc GitHub tag (latest SemVer)

For more information see nested.

nested: union

  • PubSub: Access nested union values lock-free at runtime.
  • Follow: Access nested union values via object path.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Boolean

type Boolean bool

Boolean is a Union Type

type Common

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

Common contains a not nested Union.

func New

func New(v Union) Common

New initialize a Common not nested Union.

func (Common) Follow

func (c Common) Follow(path string) (v UnionI, ok bool)

Follow a Common type returns the contained type if path is a default string.

func (Common) String

func (c Common) String() string

String implements the Stringer interface.

func (Common) Value

func (c Common) Value() Union

Value is a helper method that allows you to use nested union values and Common types. It returns always the contained Union.

type CommonList

type CommonList []UnionI

CommonList is a nested Union list.

func List

func List(l ...UnionI) CommonList

List initialize a CommonList.

func (CommonList) Follow

func (l CommonList) Follow(path string) (v UnionI, ok bool)

Follow a CommonList type returns the nested Union object if the path is a default string. In all others cases it traverses the object path. It returns the default Union and false it the path is wrong. The first element of the path has to be an integer.

func (CommonList) Value

func (l CommonList) Value() (v Union)

Value is a helper method that allows you to use nested union values and Common types. It returns always the default Union.

type CommonObject

type CommonObject map[string]UnionI

CommonObject is a nested Union object.

func Object

func Object(o map[string]UnionI) CommonObject

Object initialize a CommonObject.

func (CommonObject) Follow

func (o CommonObject) Follow(path string) (v UnionI, ok bool)

Follow a CommonObject type returns the nested Union object if the path is a default string. In all others cases it traverses the object path. It returns the default Union and false it the path is wrong.

func (CommonObject) Value

func (o CommonObject) Value() (v Union)

Value is a helper method that allows you to use nested union values and Common types. It returns always the default Union.

type Job

type Job struct {
	SubPaths []string
	Work     Work
}

A Job defines the Work that has to be done when all SubPaths are solved.

type Number

type Number float64

Number is a Union Type

type Text

type Text string

Text is a Union Type

type Union

type Union interface {
	// contains filtered or unexported methods
}

Union is base type of the nested UnionI.

type UnionI

type UnionI interface {
	Follow(path string) (n UnionI, ok bool)
	Value() Union
}

UnionI is the interface that all nested values have to implement.

func PubSub

func PubSub(ctx context.Context, jobs map[string]Job) (v UnionI, err error)

PubSub returns the value of the last running Work. Each subscriber path of a Job has to be equal or a child of a publisher path.

type Work

type Work func(subs map[string]UnionI) UnionI

Work is a function that is triggered when all SubPaths of a Job are solved.

Jump to

Keyboard shortcuts

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