namespace

package
v0.0.0-...-21d6f6e Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyPath = path("")
)

Functions

func ExistsTemplateFunc

func ExistsTemplateFunc(ctx context.Context) interface{}

Template function that returns a True or False that a path exists

func GetTemplateFunc

func GetTemplateFunc(ctx context.Context) interface{}

Template function that returns a string at the path/url

func ListTemplateFunc

func ListTemplateFunc(ctx context.Context) interface{}

Template function that returns a list of members as string

func Register

func Register(protocol string, impl Implementation)

func RegisterSanitizer

func RegisterSanitizer(protocol string, impl UrlSanitizer)

func Source

func Source(ctx context.Context, url string) ([]byte, error)

Generic implementation using the registry API to implement template package's Source function. This function is registered by specific backend implementation packages (e.g. zk).

Types

type Change

type Change struct {
	Path    `json:"path"`
	Trigger `json:"-"`
}

type Create

type Create struct {
	Path    `json:"path"`
	Trigger `json:"-"`
}

type Delete

type Delete struct {
	Path    `json:"path"`
	Trigger `json:"-"`
}

type Implementation

type Implementation func(ctx context.Context, url net.URL, dispose store.Dispose) (Registry, error)

Registry backend implementations should follow this protocol to implement and register its services.

type Members

type Members struct {
	Path         `json:"path"`
	Min          *int `json:"min,omitempty"`
	Max          *int `json:"max,omitempty"`
	Delta        *int `json:"delta,omitempty"`         // delta of count
	OutsideRange bool `json:"outside_range,omitempty"` // default is within range.  true for outside range.
	Trigger      `json:"-"`
}

For equality, set both min and max. For not equals, set min, max and OutsideRange to true.

func (*Members) SetDelta

func (this *Members) SetDelta(d int) *Members

func (*Members) SetMax

func (this *Members) SetMax(max int) *Members

func (*Members) SetMin

func (this *Members) SetMin(min int) *Members

func (*Members) SetOutsideRange

func (this *Members) SetOutsideRange(b bool) *Members

type NotSupportedProtocol

type NotSupportedProtocol struct {
	Protocol string
}

func (*NotSupportedProtocol) Error

func (this *NotSupportedProtocol) Error() string

type Path

type Path interface {
	String() string
	Sub(...string) Path
	Base() string
	Dir() Path
	IsAbs() bool
	Parts() []string
}

func FromUrl

func FromUrl(url *url.URL) Path

func NewPath

func NewPath(s string, parts ...string) Path

func NewPathf

func NewPathf(format string, args ...interface{}) Path

type Registry

type Registry interface {
	io.Closer
	Id() url.URL
	Exists(Path) (bool, error)
	Get(Path) ([]byte, Version, error)
	Put(Path, []byte, bool) (Version, error)           // Create or set.
	PutVersion(Path, []byte, Version) (Version, error) // Create or set with CAS - not for ephemeral nodes
	Delete(Path) error
	DeleteVersion(Path, Version) error // Delete with CAS
	List(Path) ([]Path, error)
	Trigger(Trigger) (<-chan interface{}, chan<- int, error) // events channel, channel to stop, error
}

func Dial

func Dial(ctx context.Context, url string) (Registry, error)

Get an instance of the registry. The url can specify host(s) such as zk://host1:2181,host2:2181,host3:2181/other/parts/of/path The protocol / scheme portion is used to dispatch to different registry implementations (e.g. zk: for zookeeper etcd: for ectd, etc.)

type Timeout

type Timeout time.Duration

func (*Timeout) MarshalJSON

func (this *Timeout) MarshalJSON() ([]byte, error)

func (*Timeout) UnmarshalJSON

func (this *Timeout) UnmarshalJSON(s []byte) error

type Trigger

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

The Trigger interface is designed so that it's not possible to implement this interface outside this package.

type UrlSanitizer

type UrlSanitizer func(url net.URL) net.URL

type Version

type Version int32
const (
	InvalidVersion Version = -1
)

func FollowUrl

func FollowUrl(ctx context.Context, url net.URL) (net.URL, []byte, Version, error)

Given the fully specified url that includes protocol and host and path, traverses symlinks where the value of a node is a pointer url to another registry node It's possible that the pointer points to a different registry. The returned url includes protocol and host information

Jump to

Keyboard shortcuts

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