remote

package
v0.0.0-...-895b022 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

A config Store able to load and store configs via simple HTTP requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadEndpoint

func ReadEndpoint(endpoint Endpoint, upath string) ([]byte, error)

func WriteEndpoint

func WriteEndpoint(endpoint Endpoint, upath string, data []byte) error

Types

type DNS

type DNS struct {
	DNSFlags
	// contains filtered or unexported fields
}

func NewDNS

func NewDNS(domain string, mods ...DNSModifier) *DNS

func (*DNS) GetEndpoints

func (d *DNS) GetEndpoints() ([]Endpoint, []error)

func (*DNS) Name

func (d *DNS) Name() string

func (*DNS) Open

func (d *DNS) Open(app string, namespaces ...string) (*Remote, error)

type DNSFlags

type DNSFlags struct {
	Timeout time.Duration
	Prefix  string
	Retry   *retry.Flags
}

func DefaultDNSFlags

func DefaultDNSFlags() *DNSFlags

func (*DNSFlags) Register

func (fl *DNSFlags) Register(set kflags.FlagSet, prefix string) *DNSFlags

type DNSModifier

type DNSModifier func(*DNS)

func FromDNSFlags

func FromDNSFlags(flags *DNSFlags) DNSModifier

func WithLogger

func WithLogger(log logger.Logger) DNSModifier

func WithPrefix

func WithPrefix(prefix string) DNSModifier

func WithRetry

func WithRetry(retry *retry.Options) DNSModifier

func WithTimeout

func WithTimeout(duration time.Duration) DNSModifier

type DNSModifiers

type DNSModifiers []DNSModifier

type DNSOptions

type DNSOptions map[string]string

func ParseDNSOptions

func ParseDNSOptions(value string) (DNSOptions, error)

func ParseTXTRecord

func ParseTXTRecord(record string) (DNSOptions, *url.URL, error)

ParseTXTRecord decodes the content of a TXT record.

TXT records are expected to either be a simple URL, like "http://mydomain.com/configs/", or a set of options followed by |, followed by the URL.

For example:

timeout=3 retries=5|http://mydomain.com/configs/

If the option needs to contain the | or any other forbidden character, the option can be URL path encoded, with characters replaced by % notation. % itself needs to be escaped.

func (DNSOptions) Apply

func (do DNSOptions) Apply(target interface{}, fns ...mapstructure.DecodeHookFunc) ([]string, error)

type Endpoint

type Endpoint struct {
	Options DNSOptions
	URL     *url.URL
	Timeout time.Duration
}

type HTTP

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

func NewHTTP

func NewHTTP(endpoints []Endpoint) (*HTTP, error)

func (*HTTP) Open

func (u *HTTP) Open(app string, namespaces ...string) (*Remote, error)

type NotFoundError

type NotFoundError struct {
	Record string
}

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Remote

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

func (*Remote) Read

func (r *Remote) Read(name string) ([]byte, error)

func (*Remote) Write

func (r *Remote) Write(name string, data []byte) error

type WritePolicy

type WritePolicy int
const (
	// Attempts to write to all endpoints. Succeeds if all succeed.
	WriteSucceedAll WritePolicy = iota
	// Attempts to write to all endpoints. Succeeds if at least one write succeeds.
	WriteSucceedOne
	// Attempts to write until a write succeeds. Not all endpoints will be written to.
	WriteFirst
)

Jump to

Keyboard shortcuts

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