simplerelation

package
v0.0.0-...-c60bc85 Latest Latest
Warning

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

Go to latest
Published: May 19, 2017 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

The simplerelation package implements a generic simple relation where the provider units each make a set of attributes available, and the requirer units can see those attributes.

It allows only one provider service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

Provider represents the provider side of a simple relation.

func (*Provider) Register

func (p *Provider) Register(r *hook.Registry, relationName, interfaceName string)

Register registers the provider side of a simple relation with the given relation name and interface.

It makes the values set by the SetValues method available to all requirers.

func (*Provider) SetValues

func (p *Provider) SetValues(vals map[string]string) error

SetValues makes the given relation attributes and values available to all requirer-side units of the relation.

type Requirer

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

Requirer represents the requirer side of a simple relation. It allows only one provider service. it makes all attributes set by units on the provider side of the relation available through the Values method.

func (*Requirer) Register

func (req *Requirer) Register(r *hook.Registry, relationName, interfaceName string)

Register registers a requirer relation with the given relation name and interface with the given hook registry.

To find out when the provider values change, register a wildcard ("*") hook, which will trigger when any value changes.

func (*Requirer) Strings

func (req *Requirer) Strings(convert func(map[string]string) (string, error)) []string

Strings is a convenience method that converts the values returned by Values into a slice of strings by calling the given convert function for each unit.

Errors found when doing the conversion are logged but otherwise ignored. If the convert function returns an empty string with no error, that string will be omitted too.

The result is stable across calls.

func (*Requirer) Values

func (req *Requirer) Values() map[hook.UnitId]map[string]string

Values returns the values provided by all the provider units, as a map from unit id to attributes to values.

Jump to

Keyboard shortcuts

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