text

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: text

  • PubSub: Access nested string values lock-free at runtime.

  • Follow: Access nested string values via object path.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Common

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

Common contains a not nested Text.

func New

func New(v Text) Common

New initialize a Common not nested Text.

func (Common) Follow

func (c Common) Follow(path string) (v TextI, 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() Text

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

type CommonList

type CommonList []TextI

CommonList is a nested Text list.

func List

func List(l ...TextI) CommonList

List initialize a CommonList.

func (CommonList) Follow

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

Follow a CommonList type returns the nested Text object if the path is a default string. In all others cases it traverses the object path. It returns the default Text 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 Text)

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

type CommonObject

type CommonObject map[string]TextI

CommonObject is a nested Text object.

func Object

func Object(o map[string]TextI) CommonObject

Object initialize a CommonObject.

func (CommonObject) Follow

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

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

func (CommonObject) Value

func (o CommonObject) Value() (v Text)

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

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 Text

type Text string

Text is the base type of the nested TextI.

type TextI

type TextI interface {
	Follow(path string) (n TextI, ok bool)
	Value() Text
}

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

func PubSub

func PubSub(ctx context.Context, jobs map[string]Job) (v TextI, 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]TextI) TextI

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