client

package
v0.0.0-...-a021210 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CCApi

type CCApi interface {
	GetServiceInfoList(serviceID string) (map[string]string, error)
	GetServiceList() (ServiceList, error)
	InitCCentral(etcdHost string) error
	GetInstanceList(serviceID string) (map[string]map[string]interface{}, error)
	SetConfigItem(serviceID string, keyID string, value string) (string, error)
	GetSchema(serviceID string) (map[string]SchemaItem, error)
	SetSchema(serviceID string, schema map[string]SchemaItem) error
	GetConfig(serviceID string) (map[string]ConfigItem, error)
}

CCApi - Interface for CCentral methods

type CCClientApi

type CCClientApi interface {
	SetSchema(serviceID string, schema map[string]SchemaItem) error
	GetConfig(serviceID string) (map[string]ConfigItem, error)
}

type CCClientReadApi

type CCClientReadApi interface {
	GetConfig(serviceID string) (map[string]ConfigItem, error)
}

type CCClientWriteApi

type CCClientWriteApi interface {
	SetSchema(serviceID string, schema map[string]SchemaItem) error
}

type CCInit

type CCInit interface {
	InitCCentral(etcdHost string) error
}

type CCServerReadApi

type CCServerReadApi interface {
	GetServiceInfoList(serviceID string) (map[string]string, error)
	GetServiceList() (ServiceList, error)
	GetInstanceList(serviceID string) (map[string]map[string]interface{}, error)
	GetSchema(serviceID string) (map[string]SchemaItem, error)
	GetConfig(serviceID string) (map[string]ConfigItem, error)
}

type CCServerWriteApi

type CCServerWriteApi interface {
	SetConfigItem(serviceID string, keyID string, value string) (string, error)
	SetSchema(serviceID string, schema map[string]SchemaItem) error
}

type CCService

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

CCService - ...

func (*CCService) GetConfig

func (cc *CCService) GetConfig(serviceID string) (map[string]ConfigItem, error)

GetConfig returns full listing of service configuration

func (*CCService) GetInstanceList

func (cc *CCService) GetInstanceList(serviceID string) (map[string]map[string]interface{}, error)

GetInstanceList returns full information of each running service instance

func (*CCService) GetSchema

func (cc *CCService) GetSchema(serviceID string) (map[string]SchemaItem, error)

GetSchema returns configuration schema

func (*CCService) GetServiceInfoList

func (cc *CCService) GetServiceInfoList(serviceID string) (map[string]string, error)

GetServiceInfoList returns list of service shared service information reported by the clients

func (*CCService) GetServiceList

func (cc *CCService) GetServiceList() (ServiceList, error)

GetServiceList returns list of available services

func (*CCService) InitCCentral

func (cc *CCService) InitCCentral(etcdHost string) error

InitCCentral will initialize everything required for CCentral usage

func (*CCService) SetConfigItem

func (cc *CCService) SetConfigItem(serviceID string, keyID string, value string) (string, error)

SetConfigItem allows changing the service configuration

func (*CCService) SetSchema

func (cc *CCService) SetSchema(serviceID string, schema map[string]SchemaItem) error

SetSchema writes the new schema to the etcd

type CCentralService

type CCentralService struct {
	CheckIntervalSeconds int64
	// contains filtered or unexported fields
}

CCentralService is base struct for CCentral services

func InitCCentralService

func InitCCentralService(cc CCApi, serviceID string) *CCentralService

InitCCentralService returns service struct for easier configuration access

func (*CCentralService) AddSchema

func (s *CCentralService) AddSchema(configID string, defaultValue string, valueType string, title string, description string)

AddSchema adds a single schema item into configuration

func (*CCentralService) ForceUpdateConfig

func (s *CCentralService) ForceUpdateConfig() error

ForceUpdateConfig will force configuration update

func (*CCentralService) GetConfig

func (s *CCentralService) GetConfig(configID string) (string, error)

GetConfig returns single configuration option

func (*CCentralService) GetConfigBool

func (s *CCentralService) GetConfigBool(configID string) (bool, error)

GetConfigBool returns boolean value of the configuration options

func (*CCentralService) GetConfigInt

func (s *CCentralService) GetConfigInt(configID string) (int, error)

GetConfigInt returns integer value of the configuration options

func (*CCentralService) UpdateConfig

func (s *CCentralService) UpdateConfig() error

UpdateConfig updates configuration CheckIntervalSeconds has passed since last check

type ConfigItem

type ConfigItem struct {
	Value   string `json:"value"`
	Changed int64  `json:"changed"`
}

ConfigItem contains value and timestamp when the value was last changed

func NewConfigItem

func NewConfigItem(value string, changed int64) *ConfigItem

NewConfigItem - Value container for configuration entry (based on SchemaItem)

type InstanceItem

type InstanceItem struct {
	Version   string  `json:"v"`
	Timestamp float64 `json:"ts"`
}

InstanceItem contains required fields for each instance

type SchemaItem

type SchemaItem struct {
	Default     string `json:"default"`
	Type        string `json:"type"`
	Title       string `json:"title"`
	Description string `json:"description"`
}

SchemaItem describes single configuration schema

func NewSchemaItem

func NewSchemaItem(defaultValue, itemType, title, description string) *SchemaItem

NewSchemaItem - Represents single entry in schema which contains metadata for ConfigItem

type Service

type Service struct {
	Schema    map[string]SchemaItem             `json:"schema"`
	Config    map[string]ConfigItem             `json:"config"`
	Instances map[string]map[string]interface{} `json:"clients"`
	Info      map[string]string                 `json:"info"`
}

Service is a container for all service data

func NewService

func NewService(
	schema map[string]SchemaItem,
	config map[string]ConfigItem,
	instances map[string]map[string]interface{},
	info map[string]string) *Service

NewService - Create a new service container

type ServiceList

type ServiceList struct {
	Services []string `json:"services"`
}

ServiceList contains list of serviceIDs

Jump to

Keyboard shortcuts

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