Documentation
¶
Index ¶
- Constants
- func Provide() fx.Option
- type Endpoint
- type FileIngester
- type FileIngesterOption
- func WithDiscoveryDomain(domain string) FileIngesterOption
- func WithGlobs(more ...string) FileIngesterOption
- func WithGroupsConfig(gcfg config.Groups) FileIngesterOption
- func WithIngestListeners(more ...IngestListener) FileIngesterOption
- func WithIngestLogger(base *zap.Logger) FileIngesterOption
- func WithOrigin(origin string) FileIngesterOption
- func WithTTL(ttl time.Duration) FileIngesterOption
- type Group
- type GroupDefinition
- type Groups
- type IngestChecker
- type IngestCheckerOption
- type IngestEvent
- type IngestListener
- type Ingester
- type LocatedEndpoints
- type Locator
- type LocatorOption
- type RRCollector
Constants ¶
const ( // DefaultFileIngesterOrigin is the default $ORIGIN used for parsing zone files. DefaultFileIngesterOrigin = "" // DefaultFileIngesterTTL is the default $TTL used for parsing zone files. DefaultFileIngesterTTL = 5 * time.Minute )
const ( // DefaultCheckInterval is the default time that a FileIngester rechecks external sources // for DNS RRs that affect how hashy operates. DefaultCheckInterval = 10 * time.Minute )
const (
DefaultDiscoveryDomain = "_hashy.discover"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint is a single endpoint of a service.
func (*Endpoint) OriginalName ¶
OriginalName is the name as it appeared in the source DNS records. This will likely be served from a different domain.
type FileIngester ¶
type FileIngester struct {
// contains filtered or unexported fields
}
FileIngester handles reading in DNS zone files from the filesystem.
func NewFileIngester ¶
func NewFileIngester(opts ...FileIngesterOption) (*FileIngester, error)
NewFileIngester creates a FileIngester from a set of options.
func (*FileIngester) Ingest ¶
func (fi *FileIngester) Ingest(ctx context.Context)
Ingest reads in all the files this FileIngester was configured with. This method tracks the checksum across all files. An IngestEvent will only be dispatch if either (a) this is the first Ingest, or (b) if any change in the files occurred.
type FileIngesterOption ¶
type FileIngesterOption interface {
// contains filtered or unexported methods
}
func WithDiscoveryDomain ¶
func WithDiscoveryDomain(domain string) FileIngesterOption
func WithGlobs ¶
func WithGlobs(more ...string) FileIngesterOption
func WithGroupsConfig ¶
func WithGroupsConfig(gcfg config.Groups) FileIngesterOption
func WithIngestListeners ¶
func WithIngestListeners(more ...IngestListener) FileIngesterOption
func WithIngestLogger ¶
func WithIngestLogger(base *zap.Logger) FileIngesterOption
func WithOrigin ¶
func WithOrigin(origin string) FileIngesterOption
func WithTTL ¶
func WithTTL(ttl time.Duration) FileIngesterOption
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a single group of servers.
type GroupDefinition ¶
GroupDefinition holds the discovered information about a group. Typically, group definitions will come from TXT records.
func MergeGroupDefinitions ¶
func MergeGroupDefinitions(defs ...GroupDefinition) (merged GroupDefinition)
MergeGroupDefinitions merges each of a sequence of definitions into a single definition. The returned definition has the name of the first definition passed to this function. The services are merged into a single slice, but are not deduped or sorted.
If no definitions are passed to this function, it returns an empty definition.
func ParseGroupDefinition ¶
func ParseGroupDefinition(txt string) (gdef GroupDefinition, err error)
ParseGroupDefinition parses the textual representation of a group's discovered information. The text must be a valid US-ASCII string with 2 or more fields delimited by whitespace. The first field is the group's name, and all subsequent fields are the services (SRV records) that hold the members of the group.
type Groups ¶
type Groups struct {
// contains filtered or unexported fields
}
Groups is an immutable collection of Group instances.
type IngestChecker ¶
type IngestChecker struct {
// contains filtered or unexported fields
}
IngestChecker manages a single goroutine that invokes Ingest on a particular Ingester on an interval.
Only (1) background goroutine will run for any given IngestChecker.
func NewIngestChecker ¶
func NewIngestChecker(opts ...IngestCheckerOption) (*IngestChecker, error)
NewIngestChecker creates an unstarted IngestChecker using the supplied options. If no Ingester was supplied in the options, this method returns an error.
func (*IngestChecker) Start ¶
func (ic *IngestChecker) Start()
Start atomically starts invoking Ingest on the configured interval. This method is idempotent.
func (*IngestChecker) Stop ¶
func (ic *IngestChecker) Stop()
Stop atomically halts invoking Ingest. This method is idempotent.
type IngestCheckerOption ¶
type IngestCheckerOption interface {
// contains filtered or unexported methods
}
func WithCheckInterval ¶
func WithCheckInterval(v time.Duration) IngestCheckerOption
func WithIngester ¶
func WithIngester(i Ingester) IngestCheckerOption
type IngestEvent ¶
type IngestEvent struct {
// Err contains any error that occurred. If this is non-nil, Groups
// should be ignored.
Err error
// Lists holds the ingested groups.
Groups *Groups
}
IngestEvent holds information about an update to the set of groups.
type IngestListener ¶
type IngestListener interface {
// OnIngest notifies this listener that an ingest operation has completed.
// Only errors and actual changes will be dispatched through this method.
OnIngest(IngestEvent)
}
IngestListener is a sink for IngestEvents.
type Ingester ¶
type Ingester interface {
// Ingest reads group information, usually DNS RRs, from the configured source.
// This method dispatches an IngestEvent that will contain the new groups as well
// as any error that occurred.
Ingest(context.Context)
}
Ingester represents the behavior of something that can read in group information. Primarily, this will be from some source of DNS RRs.
type LocatedEndpoints ¶
type LocatedEndpoints []*Endpoint
LocatedEndpoints is a collection of endpoints that were discovered by a Locator.
func (LocatedEndpoints) LenRRs ¶
func (le LocatedEndpoints) LenRRs(rrType uint16) (n int)
LenRRs returns the total count of all RRs of a given type in this set. This will be the number of tuples returned by the RRs() sequence.
type Locator ¶
type Locator struct {
// contains filtered or unexported fields
}
Locator is a service locator backed by one or more medley consistent hash Rings.
func NewLocator ¶
func NewLocator(opts ...LocatorOption) (*Locator, error)
func (*Locator) Find ¶
func (l *Locator) Find(object []byte, groups ...string) (results LocatedEndpoints)
func (*Locator) FindString ¶
func (l *Locator) FindString(object string, groups ...string) (results LocatedEndpoints)
func (*Locator) OnIngest ¶
func (l *Locator) OnIngest(event IngestEvent)
type LocatorOption ¶
type LocatorOption interface {
// contains filtered or unexported methods
}
func WithLocatorLogger ¶
func WithLocatorLogger(base *zap.Logger) LocatorOption
func WithVNodes ¶
func WithVNodes(vnodes int) LocatorOption
type RRCollector ¶
type RRCollector struct {
// contains filtered or unexported fields
}
RRCollector collects DNS resource records in order to build a Groups. This type is basically the recipient of a stream of incoming RRs from an arbitrary source.
func (*RRCollector) AddRR ¶
func (rrc *RRCollector) AddRR(rr dns.RR) error
AddRR adds an RR to this collector. Any RR that is not recognized is simply ignored.
func (*RRCollector) Build ¶
func (rrc *RRCollector) Build() *Groups
Build constructs a Groups from the collected DNS RRs. After this method returns, this builder will be Reset.
func (*RRCollector) Reset ¶
func (rrc *RRCollector) Reset()
Reset clears all collected records, but retains the underlying storage buffers for next time.