registry

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Observe

func Observe(registry Registry, period time.Duration) (<-chan ObserveRegistryResult, func())

Observe the registry for changes returns json bytes and errors via channels

Types

type ConstantRegistry

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

ConstantRegistry is a registry that always returns the same JSON value it can be created from a JSON string or from a file path

func (*ConstantRegistry) GetJSON

func (c *ConstantRegistry) GetJSON() ([]byte, error)

func (*ConstantRegistry) RegistryType

func (c *ConstantRegistry) RegistryType() RegistryType

type ObserveRegistryResult

type ObserveRegistryResult struct {
	Json []byte
	Err  error
}

type Registry

type Registry interface {
	RegistryType() RegistryType
	GetJSON() ([]byte, error)
}

Registry is the interface for the JSON registry It is used to get the JSON bytes representing a set of endpoints to redirects

func NewRegistry

func NewRegistry(source string) (Registry, error)

getRegistry will check if the given string is a) a JSON by itself b) if is a path to a file c) remote url

type RegistryType

type RegistryType int

RegistryType is an enum-like type that represents the type of registry useful to conditionally observe the registry according to its type

const (
	ConstantRegistryType RegistryType = iota
	RemoteRegistryType
)

type RemoteRegistry

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

RemoteRegistry represents a registry that is fetched from a remote URL it can be created from a valid URL returning the JSON value on http GET request

func (*RemoteRegistry) GetJSON

func (r *RemoteRegistry) GetJSON() ([]byte, error)

func (*RemoteRegistry) RegistryType

func (r *RemoteRegistry) RegistryType() RegistryType

Jump to

Keyboard shortcuts

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