Documentation ¶
Index ¶
- Constants
- func MainTask(app *gopi.AppInstance, done chan<- struct{}) error
- func ProcessEvent(app *gopi.AppInstance, server gopi.RPCServer, ...) error
- func RegisterTask(app *gopi.AppInstance, start chan<- struct{}, stop <-chan struct{}) error
- func Server(config gopi.AppConfig, background_tasks ...gopi.BackgroundTask) int
- func ServerTask(app *gopi.AppInstance, start chan<- struct{}, stop <-chan struct{}) error
- type DiscoveryClient
- type DiscoveryType
- type Gaffer
- type GafferClient
- type GafferEvent
- type GafferEventType
- type GafferService
- type GafferServiceGroup
- type GafferServiceInstance
- type GafferServiceMode
- type GoogleCast
- type GoogleCastClient
- type GoogleCastDevice
- type GoogleCastEvent
- type GreeterClient
- type ServiceRecord
- type Tuples
- func (this Tuples) Copy() Tuples
- func (this Tuples) Env() []string
- func (this Tuples) Equals(that Tuples) bool
- func (this *Tuples) ExistsForKey(k string) bool
- func (this Tuples) Flags() []string
- func (this *Tuples) Keys() []string
- func (this *Tuples) Len() int
- func (t Tuples) MarshalJSON() ([]byte, error)
- func (this *Tuples) RemoveAll()
- func (this *Tuples) SetStringForKey(k, v string) error
- func (this Tuples) String() string
- func (this *Tuples) StringForKey(k string) string
- func (t *Tuples) UnmarshalJSON(data []byte) error
- type Util
- type VersionClient
Constants ¶
View Source
const (
DISCOVERY_SERVICE_QUERY = "_services._dns-sd._udp"
)
Variables ¶
This section is empty.
Functions ¶
func MainTask ¶ added in v1.0.11
func MainTask(app *gopi.AppInstance, done chan<- struct{}) error
func ProcessEvent ¶ added in v1.0.11
func ProcessEvent(app *gopi.AppInstance, server gopi.RPCServer, discovery gopi.RPCServiceDiscovery, evt gopi.RPCEvent) error
func RegisterTask ¶ added in v1.0.11
func RegisterTask(app *gopi.AppInstance, start chan<- struct{}, stop <-chan struct{}) error
func Server ¶ added in v1.0.11
func Server(config gopi.AppConfig, background_tasks ...gopi.BackgroundTask) int
func ServerTask ¶ added in v1.0.11
func ServerTask(app *gopi.AppInstance, start chan<- struct{}, stop <-chan struct{}) error
Types ¶
type DiscoveryClient ¶ added in v1.0.7
type DiscoveryClient interface { gopi.RPCClient // Ping the remote service instance Ping() error // Register a service record Register(gopi.RPCServiceRecord) error // Enumerate service names Enumerate(DiscoveryType, time.Duration) ([]string, error) // Lookup service instances Lookup(string, DiscoveryType, time.Duration) ([]gopi.RPCServiceRecord, error) // Stream discovery events. filtering by service name StreamEvents(string, chan<- gopi.RPCEvent) error }
type DiscoveryType ¶ added in v1.0.6
type DiscoveryType uint
DiscoveryType is either DNS (using DNS-SD) or DB (using internal database)
const ( DISCOVERY_TYPE_NONE DiscoveryType = 0 DISCOVERY_TYPE_DNS DiscoveryType = 1 DISCOVERY_TYPE_DB DiscoveryType = 2 )
type Gaffer ¶ added in v1.0.12
type Gaffer interface { gopi.Driver gopi.Publisher // Return all services, groups, instances and executables GetServices() []GafferService GetGroups() []GafferServiceGroup GetInstances() []GafferServiceInstance GetExecutables(recursive bool) []string // Services AddServiceForPath(string) (GafferService, error) GetServiceForName(string) GafferService RemoveServiceForName(string) error SetServiceNameForName(service string, new string) error SetServiceModeForName(string, GafferServiceMode) error SetServiceInstanceCountForName(service string, count uint) error SetServiceGroupsForName(service string, groups []string) error // Groups GetGroupsForNames([]string) []GafferServiceGroup AddGroupForName(string) (GafferServiceGroup, error) SetGroupNameForName(group string, new string) error RemoveGroupForName(string) error // Tuples SetServiceFlagsForName(string, Tuples) error SetGroupFlagsForName(string, Tuples) error SetGroupEnvForName(string, Tuples) error // Instances GetInstanceForId(id uint32) GafferServiceInstance GenerateInstanceId() uint32 StartInstanceForServiceName(service string, id uint32) (GafferServiceInstance, error) StopInstanceForId(id uint32) error }
type GafferClient ¶ added in v1.0.12
type GafferClient interface { gopi.RPCClient // Ping remote microservice Ping() error // Return list of executables which can be used as microservices ListExecutables() ([]string, error) // Return services ListServices() ([]GafferService, error) ListServicesForGroup(string) ([]GafferService, error) GetService(string) (GafferService, error) // Return groups ListGroups() ([]GafferServiceGroup, error) ListGroupsForService(string) ([]GafferServiceGroup, error) GetGroup(string) (GafferServiceGroup, error) // Return instances ListInstances() ([]GafferServiceInstance, error) // Add services and groups AddServiceForPath(path string, groups []string) (GafferService, error) AddGroupForName(string) (GafferServiceGroup, error) // Remove services and groups RemoveServiceForName(string) error RemoveGroupForName(string) error // Start instances GetInstanceId() (uint32, error) StartInstance(string, uint32) (GafferServiceInstance, error) StopInstance(uint32) (GafferServiceInstance, error) // Set flags and env SetFlagsForService(string, Tuples) (GafferService, error) SetFlagsForGroup(string, Tuples) (GafferServiceGroup, error) SetEnvForGroup(string, Tuples) (GafferServiceGroup, error) // Set other service parameters SetServiceGroups(string, []string) (GafferService, error) // Stream Events StreamEvents(chan<- GafferEvent) error }
type GafferEvent ¶ added in v1.0.12
type GafferEvent interface { gopi.Event Type() GafferEventType Service() GafferService Group() GafferServiceGroup Instance() GafferServiceInstance Data() []byte }
type GafferEventType ¶ added in v1.0.12
type GafferEventType uint
const ( GAFFER_EVENT_NONE GafferEventType = iota GAFFER_EVENT_SERVICE_ADD GAFFER_EVENT_SERVICE_CHANGE GAFFER_EVENT_SERVICE_REMOVE GAFFER_EVENT_GROUP_ADD GAFFER_EVENT_GROUP_CHANGE GAFFER_EVENT_GROUP_REMOVE GAFFER_EVENT_INSTANCE_ADD GAFFER_EVENT_INSTANCE_START GAFFER_EVENT_INSTANCE_RUN GAFFER_EVENT_INSTANCE_STOP_OK GAFFER_EVENT_INSTANCE_STOP_ERROR GAFFER_EVENT_INSTANCE_STOP_KILLED GAFFER_EVENT_LOG_STDOUT GAFFER_EVENT_LOG_STDERR )
func (GafferEventType) String ¶ added in v1.0.12
func (t GafferEventType) String() string
type GafferService ¶ added in v1.0.12
type GafferServiceGroup ¶ added in v1.0.12
type GafferServiceInstance ¶ added in v1.0.12
type GafferServiceMode ¶ added in v1.0.12
type GafferServiceMode uint
const ( GAFFER_MODE_NONE GafferServiceMode = iota GAFFER_MODE_MANUAL GAFFER_MODE_AUTO )
func (GafferServiceMode) MarshalJSON ¶ added in v1.0.12
func (m GafferServiceMode) MarshalJSON() ([]byte, error)
func (GafferServiceMode) String ¶ added in v1.0.12
func (m GafferServiceMode) String() string
func (*GafferServiceMode) UnmarshalJSON ¶ added in v1.0.12
func (m *GafferServiceMode) UnmarshalJSON(data []byte) error
type GoogleCast ¶ added in v1.0.11
type GoogleCast interface { gopi.Driver gopi.Publisher Devices() []GoogleCastDevice }
type GoogleCastClient ¶ added in v1.0.11
type GoogleCastClient interface { // Ping remote service Ping() error // Return devices from the remote service Devices() ([]GoogleCastDevice, error) // Stream discovery events StreamEvents(string, chan<- GoogleCastEvent) error }
type GoogleCastDevice ¶ added in v1.0.11
type GoogleCastEvent ¶ added in v1.0.11
type GoogleCastEvent interface { gopi.Event Type() gopi.RPCEventType Device() GoogleCastDevice Timestamp() time.Time }
type GreeterClient ¶ added in v1.0.7
type ServiceRecord ¶
type ServiceRecord interface { gopi.RPCServiceRecord // Key returns the PTR record for the service record Key() string // Expired returns true if TTL has been reached Expired() bool // Source returns the source of the record Source() DiscoveryType // Get DNS answers PTR(zone string, ttl time.Duration) *dns.PTR SRV(zone string, ttl time.Duration) *dns.SRV TXT(zone string, ttl time.Duration) *dns.TXT A(zone string, ttl time.Duration) []*dns.A AAAA(zone string, ttl time.Duration) []*dns.AAAA // Set parameters SetService(service, subtype string) error SetName(name string) error SetAddr(addr string) error SetPTR(zone string, rr *dns.PTR) error SetSRV(zone string, rr *dns.SRV) error SetTTL(time.Duration) error AppendIP(...net.IP) error AppendTXT(...string) error }
type Tuples ¶ added in v1.0.12
type Tuples struct {
// contains filtered or unexported fields
}
func (*Tuples) ExistsForKey ¶ added in v1.0.12
ExistsForKey returns true if a key is present
func (Tuples) Flags ¶ added in v1.0.12
Flags returns tuples as a set of flags, including the initial '-' character
func (Tuples) MarshalJSON ¶ added in v1.0.12
func (*Tuples) RemoveAll ¶ added in v1.0.12
func (this *Tuples) RemoveAll()
RemoveAll removes all tuples
func (*Tuples) SetStringForKey ¶ added in v1.0.12
SetStringForKey sets a tuple key-value pair. Returns error if a key is invalid
func (*Tuples) StringForKey ¶ added in v1.0.12
StringForKey returns the string value for a key or an empty string if a keyed tuple was not found
func (*Tuples) UnmarshalJSON ¶ added in v1.0.12
type Util ¶ added in v1.0.7
type Util interface { gopi.Driver // NewEvent creates a new event from source, type and service record NewEvent(gopi.Driver, gopi.RPCEventType, gopi.RPCServiceRecord) gopi.RPCEvent // NewServiceRecord creates an empty service record NewServiceRecord(source DiscoveryType) ServiceRecord // Read and write array of service records Writer(fh io.Writer, records []ServiceRecord, indent bool) error Reader(fh io.Reader) ([]ServiceRecord, error) }
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
helloworld-client
An example RPC Client tool
|
An example RPC Client tool |
helloworld-service
An RPC Server tool, import the services as modules
|
An RPC Server tool, import the services as modules |
rpc
|
|
sys
|
|
Click to show internal directories.
Click to hide internal directories.