director

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UP   = RegistrationStatus("UP")
	DOWN = RegistrationStatus("DOWN")
)

Variables

View Source
var ErrInvalidHostIP = errors.New("invalid hostname or ip address")
View Source
var ErrInvalidHostname = errors.New("invalid hostname")
View Source
var ErrInvalidPort = errors.New("invalid port")

Functions

func EncodeHostnameToKey

func EncodeHostnameToKey(hostname string) string

EncodeHostnameToKey will replace the . and : characters in a hostname with a dash

Types

type DirectorOptsFunc

type DirectorOptsFunc func(config *directorRegistrationOpts) error

func WithAuthorization

func WithAuthorization(authorization string) DirectorOptsFunc

WithAuthorization will set the authorization

func WithInterval

func WithInterval(interval time.Duration) DirectorOptsFunc

WithInterval will change the duration renewal time

func WithRegion

func WithRegion(region string) DirectorOptsFunc

WithRegion will change the region

func WithURL

func WithURL(url string) DirectorOptsFunc

WithURL will allow the director url to be overriden from the default value

type DirectorRegister

type DirectorRegister interface {
	// Close will unregister and then shutdown
	Close() error
}

func NewRegistration

func NewRegistration(logger logger.Logger, hostname string, hostIP string, port int, opts ...DirectorOptsFunc) (DirectorRegister, error)

NewRegistration will create a director registration for hostname with upstream hostIP and port

type Registration

type Registration struct {
	Timestamp time.Time          `json:"timestamp"`
	Status    RegistrationStatus `json:"status"`
	Region    string             `json:"region"`
	IPAddress string             `json:"ipAddress"`
	Port      *int               `json:"port,omitempty"`
	Hostname  string             `json:"hostname"`
}

Registration is a record for director registration

func (Registration) GetPort

func (r Registration) GetPort() int

GetPort will return a port using default if not provided

func (Registration) IsUP

func (r Registration) IsUP() bool

IsUP returns true if this is an up status

func (Registration) Key

func (r Registration) Key() string

Key should return a suitable cache key using the host ip and port

type RegistrationStatus

type RegistrationStatus string

Jump to

Keyboard shortcuts

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