spawnable

package
v1.0.0-RC1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2018 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

This is a convenience package for supplying configuration parameters and applying metadata to a BOSSWAVE driver which provides services and interfaces.

The following keys are expected and used by spawnable:

  • svc_base_uri: the full BOSSWAVE URI prefix for where this driver will be deployed
  • metadata: tiered map of key-value pairs to be applied to different levels in the driver URI hierarchy
  • metavalid: string formatted like "2006-01-02T15:04:05 MST" specifying when the metadata was considered valid

Metadata

Metadata in spawnable is applied as a set of key-value pairs persisted at some URI. The URIs specified in the file are relative to `svc_base_uri`.

Example:

# params.yml
metadata:
	- s.servicename:
		- key1: value1
		- key2: value2
	- s.servicename/instance:
		- key3: value3
	- s.servicename/instance/i.name:
		- key4: value4
		- key5: value5

If `svc_base_uri` was `scratch.ns/services`, then metadata would be placed at the following URIs:

scratch.ns/services/s.servicename/!meta/key1
scratch.ns/services/s.servicename/!meta/key2
scratch.ns/services/s.servicename/instance/!meta/key3
scratch.ns/services/s.servicename/instance/i.name/!meta/key4
scratch.ns/services/s.servicename/instance/i.name/!meta/key5

Inheritance of this metadata is dictated by the semantics of the BOSSWAVE query tool, which will "trickle down" metadata from prefixes to the longer URIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetaTuple

type MetaTuple struct {
	Val string `yaml:"val"`
	TS  string `yaml:"ts"`
	// contains filtered or unexported fields
}

func (*MetaTuple) NewerThan

func (mt *MetaTuple) NewerThan(t time.Time) bool

Returns true if the current valid time of the metadata tuple is newer/more recent than the given time

type Params

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

Key value structure representing the paramater file

func GetParams

func GetParams() (p *Params, e error)

Loads params from YAML file 'params.yml'

func GetParamsFile

func GetParamsFile(filename string) (p *Params, e error)

Loads parameters from the given YAML file

func GetParamsFileOrExit

func GetParamsFileOrExit(filename string) *Params

Loads parameters from the given YAML file or exits

func GetParamsOrExit

func GetParamsOrExit() *Params

Loads params from 'params.yml' or exits

func (*Params) GetEntity

func (p *Params) GetEntity() (blob []byte, err error)

func (*Params) GetEntityOrExit

func (p *Params) GetEntityOrExit() (blob []byte)

func (*Params) MergeMetadata

func (p *Params) MergeMetadata(cl *bw2bind.BW2Client)

Applies metadata from the different suffixes in the params to their respective URIs

func (*Params) MergeMetadataOnURI

func (p *Params) MergeMetadataOnURI(md []*MetaTuple, uriSuffix string, cl *bw2bind.BW2Client)

given a k/v map of metadata, applies these as MetadataTuples on the given uriSuffix, which will be prefixed with `svc_base_uri`, considered valid from the time provided in `metavalid`

func (*Params) MustInt

func (p *Params) MustInt(key string) int

func (*Params) MustString

func (p *Params) MustString(key string) string

func (*Params) MustStringSlice

func (p *Params) MustStringSlice(key string) []string

func (*Params) ParamsMetadataFromURI

func (p *Params) ParamsMetadataFromURI(uriSuffix string) []*MetaTuple

pulls the k/v pairs from the given URI suffix under the 'metadata' tag in params

type SmartPoller

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

func NewSmartPoller

func NewSmartPoller(minInterval, maxInterval, adjust time.Duration, cb func()) *SmartPoller

A smart poller will call cb every interval, and double the interval every adjust, up to maxInterval. If reset(), the interval goes down to minInterval

func (*SmartPoller) Reset

func (sp *SmartPoller) Reset()

Jump to

Keyboard shortcuts

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