bag

package
v0.0.0-...-df570b3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *googleContext

FromContext returns a new context object that meets the Context interface.

Types

type Fields

type Fields map[interface{}]interface{}

Fields defines a map of key:value pairs.

type Getter

type Getter interface {
	GetInt(interface{}) int
	GetBool(interface{}) bool
	GetInt8(interface{}) int8
	GetInt16(interface{}) int16
	GetInt32(interface{}) int32
	GetInt64(interface{}) int64
	Get(interface{}) interface{}
	GetString(interface{}) string
	GetFloat32(interface{}) float32
	GetFloat64(interface{}) float64
	GetDuration(interface{}) time.Duration
}

Getter defines a series of Get methods for which values will be retrieved with.

type Pair

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

Pair defines a struct for storing a linked pair of key and values.

func Append

func Append(p *Pair, key, value interface{}) *Pair

Append returns a new Pair with the giving key and with the provded Pair set as it's previous link.

func NewPair

func NewPair(key, value interface{}) *Pair

NewPair returns a a key-value pair chain for setting fields.

func (*Pair) Append

func (p *Pair) Append(key, val interface{}) *Pair

Append returns a new pair with the giving key and value and its previous set to this pair.

func (*Pair) Fields

func (p *Pair) Fields() Fields

Fields returns all internal pair data as a map.

func (*Pair) Get

func (p *Pair) Get(key interface{}) (interface{}, bool)

Get returns the value of a key if it exists.

func (*Pair) GetBool

func (p *Pair) GetBool(key interface{}) bool

GetBool returns the bool value of a key if it exists.

func (*Pair) GetDuration

func (p *Pair) GetDuration(key interface{}) time.Duration

GetDuration returns the duration value of a key if it exists.

func (*Pair) GetFloat32

func (p *Pair) GetFloat32(key interface{}) float32

GetFloat32 returns the float32 value of a key if it exists.

func (*Pair) GetFloat64

func (p *Pair) GetFloat64(key interface{}) float64

GetFloat64 returns the float64 value of a key if it exists.

func (*Pair) GetInt

func (p *Pair) GetInt(key interface{}) int

GetInt returns the value type value of a key if it exists.

func (*Pair) GetInt16

func (p *Pair) GetInt16(key interface{}) int16

GetInt16 returns the int16 value of a key if it exists.

func (*Pair) GetInt32

func (p *Pair) GetInt32(key interface{}) int32

GetInt32 returns the value type value of a key if it exists.

func (*Pair) GetInt64

func (p *Pair) GetInt64(key interface{}) int64

GetInt64 returns the value type value of a key if it exists.

func (*Pair) GetInt8

func (p *Pair) GetInt8(key interface{}) int8

GetInt8 returns the int8 value of a key if it exists.

func (*Pair) GetString

func (p *Pair) GetString(key interface{}) string

GetString returns the value type value of a key if it exists.

func (*Pair) RemoveAll

func (p *Pair) RemoveAll()

RemoveAll sets all key-value pairs to nil for all connected pair, till it reaches the root.

func (*Pair) Root

func (p *Pair) Root() *Pair

Root returns the root Pair in the chain which links all pairs together.

type ValueBag

type ValueBag interface {
	Getter

	// Set adds a key-value pair into the bag.
	Set(key, value interface{})

	// WithValue returns a new context then adds the key and value pair into the
	// context's store.
	WithValue(key interface{}, value interface{}) ValueBag
}

ValueBag defines a context for holding values to be shared across processes..

func NewValueBag

func NewValueBag() ValueBag

NewValueBag returns a new context object that meets the Context interface.

func ValueBagFrom

func ValueBagFrom(fields map[interface{}]interface{}) ValueBag

ValueBagFrom adds giving key-value pairs into the bag.

Jump to

Keyboard shortcuts

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