server

package
v0.0.0-...-6db7017 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.1.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Ballot

type Ballot struct {
	Accept      bool
	Proficiency int32
	UUID        string
}

type ConnectionConfig

type ConnectionConfig struct {
	// DialTimeout is how long a domain will wait for a grpc.ClientConn to establish
	DialTimeout time.Duration

	// IsolationCheck is the range of possible durations between isolation checks
	IsolationCheck RangeTiming
	// IsolationTimeout is the range of possible durations after which a domain will determine it is isolated
	IsolationTimeout RangeTiming

	// HeartbeatCheck is the range of possible durations after which a domain will send a heartbeat
	HeartbeatCheck RangeTiming
}

func (ConnectionConfig) Check

func (c ConnectionConfig) Check() error

func (ConnectionConfig) String

func (c ConnectionConfig) String() string

type Domain

type Domain struct {
	// System contains the halt and log of the domain.
	// System handles Signals with `go system.HandleSignals`.
	// System offers `system.Logf` and `system.Panic`.
	system.System
	// contains filtered or unexported fields
}

func NewDomain

func NewDomain(config DomainConfig) (*Domain, error)

NewDomain creates a new Domain, to correctly build the Domain, just initilize

func (*Domain) ClosePosition

func (d *Domain) ClosePosition(ctx context.Context, request *pb.ClosePositionRequest) (*pb.ClosePositionReply, error)

ClosePosition implements grpc and allows the domains to use grpc. ClosePosition serves as the begining of an election for domains.

func (*Domain) DumpIdentityList

func (d *Domain) DumpIdentityList(ctx context.Context, request *pb.DumpIdentityListRequest) (*pb.IdentityListReply, error)

DumpIdentityList implements grpc and allows the domain to use grpc. DumpIdentityList serves as the heartbeat between domains.

func (*Domain) GetServices

func (d *Domain) GetServices(ctx context.Context, request *pb.GetServicesRequest) (*pb.GetServicesReply, error)

GetServices implements grpc and allows the domains to use grpc. GetServices serves as the directory of services hosted on all domains. GetServices is called by services hosted on a single domain to find their dependencies.

func (Domain) LogfGUID

func (d Domain) LogfGUID(fmt string, args ...interface{})

func (*Domain) OpenPosition

func (d *Domain) OpenPosition(ctx context.Context, request *pb.OpenPositionRequest) (*pb.OpenPositionReply, error)

OpenPosition implements grpc and allows the domains to use grpc. OpenPosition serves as the begining of an election for domains.

func (Domain) Run

func (d Domain) Run(ctx context.Context)

func (*Domain) ShareIdentityList

func (d *Domain) ShareIdentityList(ctx context.Context, request *pb.IdentityListRequest) (*pb.IdentityListReply, error)

ShareIdentityList implements grpc and allows the domain to use grpc. ShareIdentityList serves as the heartbeat between domains.

type DomainConfig

type DomainConfig struct {
	// UUID is a unique identifier for a domain
	UUID string
	// Title is the name of the Dominion which the domain belongs to
	Title string

	// Version is the version of Code which the domain is running
	Version semver.Version

	// Traits is the traits possesed by the domain.
	Traits []string
	// Services is the list of possible services.
	Services map[string]ServiceConfig

	// Port is the port which the domain will be responding on
	Port int
	// IP is the port which the domain will be responding on
	IP net.IP

	// ConnectionConfig specifies all the values needed for autoconnecting and heartbeats
	ConnectionConfig ConnectionConfig
	// ServiceHierarchyConfig specifies all the values needed for service elections
	ServiceHierarchyConfig ServiceHierarchyConfig

	// Log is where the logs from the domain are left.
	Log *log.Logger
}

func ConfigFromTOML

func ConfigFromTOML(bytes []byte) (DomainConfig, error)

ConfigFromTOML produces a default configuration which can be passed to New()

func ConfigFromYAML

func ConfigFromYAML(bytes []byte) (DomainConfig, error)

ConfigureFromYAML produces a default configuration which can be passed to New()

func (DomainConfig) Check

func (c DomainConfig) Check() error

func (DomainConfig) Dump

func (c DomainConfig) Dump() string

type Election

type Election struct {
	// Votest
	Votes      int
	Ballots    []Ballot
	Start      time.Time
	SelfRun    bool
	ClosePolls context.CancelFunc
}

func (Election) Failed

func (e Election) Failed(totalVoters int64, requiredPercentage float64) bool

func (Election) Succeeded

func (e Election) Succeeded(totalVoters int64, requiredPercentage float64) bool

type Peer

type Peer struct {
	identity.Identity
	// RWMutex locks everypart of a member except for the UUID (which is always read)
	sync.RWMutex
	// contains filtered or unexported fields
}

peer represents another legionnaire in the Legion all methods of peer assume that the lock is held by the caller

type Priority

type Priority string
const (
	Required   Priority = "required"
	Dependency Priority = "dependency"
)

type RangeTiming

type RangeTiming struct {
	// Max is the top of the possible durations
	Max time.Duration
	// Min is the bottom of the possible durations
	Min time.Duration
}

func (RangeTiming) Check

func (r RangeTiming) Check() error

func (RangeTiming) Get

func (r RangeTiming) Get() time.Duration

func (RangeTiming) String

func (r RangeTiming) String() string

type Service

type Service struct {
	ServiceIdentity identity.ServiceIdentity
	ServiceConfig   ServiceConfig
}

func (*Service) Status

func (s *Service) Status() error

type ServiceConfig

type ServiceConfig struct {
	Name     string
	Priority Priority
	Depends  []string
	Traits   []string
}

func (ServiceConfig) String

func (s ServiceConfig) String() string

type ServiceHierarchyConfig

type ServiceHierarchyConfig struct {
	// ElectionTimeout is how long a domain will wait for an election to conclude
	ElectionTimeout time.Duration
	// RequiredPercentage is the number of nodes required for an election to move forward and select a nominee
	RequiredVotePercentage float64
	// ElectionTimeout is the range of possible durations after which a domain will cancel a pending election for a service
	ElectionBackoff RangeTiming

	// DependencyCheck is the range of possible durations between service dependency checks
	DependencyCheck RangeTiming
}

func (ServiceHierarchyConfig) Check

func (c ServiceHierarchyConfig) Check() error

func (ServiceHierarchyConfig) String

func (c ServiceHierarchyConfig) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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