Documentation ¶
Index ¶
- Constants
- func GetAgentIP(defaultRPCPort int) string
- func GetDefaultOptions(cfg utils.ConfigReader) config.Options
- func GetOptionsAgent() bool
- func GetOptionsMaster() bool
- func GetOptionsMasterPoolID() string
- func GetOptionsMaxRPCClients() int
- func GetOptionsRPCEndpoint() string
- func GetOptionsRPCPort() string
- func IDsToString(ids interface{}) string
- func NormalizeYYYYMMDD(s string) (string, error)
- func ValidateCommonOptions(opts config.Options) error
- func ValidateServerOptions(options *config.Options) error
- type API
- type AuthHost
- type CompileTemplateConfig
- type ContainerFileIndex
- func (cfi *ContainerFileIndex) AddIndexForMessage(index int, message *parsedMessage)
- func (cfi *ContainerFileIndex) FindIndexForMessage(message *parsedMessage) (index int, found bool)
- func (cfi *ContainerFileIndex) GetFileIndexData(index int, outputFile outputFileInfo, hostName, serviceName string) string
- func (cfi *ContainerFileIndex) GetFileName(index int, message *parsedMessage) string
- func (cfi *ContainerFileIndex) GetIndexHeader() string
- type DateFileIndex
- func (dfi *DateFileIndex) AddIndexForMessage(index int, message *parsedMessage)
- func (dfi *DateFileIndex) FindIndexForMessage(message *parsedMessage) (index int, found bool)
- func (dfi *DateFileIndex) GetFileIndexData(index int, outputFile outputFileInfo, hostName, serviceName string) string
- func (dfi *DateFileIndex) GetFileName(index int, message *parsedMessage) string
- func (dfi *DateFileIndex) GetIndexHeader() string
- type DeployTemplateConfig
- type ElasticSearchResults
- type ExportGroup
- type ExportLogDriver
- type ExportLogDriverMock
- func (_m *ExportLogDriverMock) LogstashDays() ([]string, error)
- func (_m *ExportLogDriverMock) ScrollSearch(scrollID string) (ElasticSearchResults, error)
- func (_m *ExportLogDriverMock) SetLogstashInfo(logstashES string) error
- func (_m *ExportLogDriverMock) StartSearch(logstashIndex string, query string) (ElasticSearchResults, error)
- type ExportLogsConfig
- type ExternalHit
- type FileIndex
- type HostConfig
- type HostUpdateConfig
- type IPConfig
- type ImageMap
- type InternalHit
- type PoolConfig
- type PortMap
- type SchedulerConfig
- type ServiceConfig
- type ServiceFileIndex
- func (sfi *ServiceFileIndex) AddIndexForMessage(index int, message *parsedMessage)
- func (sfi *ServiceFileIndex) FindIndexForMessage(message *parsedMessage) (index int, found bool)
- func (sfi *ServiceFileIndex) GetFileIndexData(index int, outputFile outputFileInfo, hostName, serviceName string) string
- func (sfi *ServiceFileIndex) GetFileName(index int, message *parsedMessage) string
- func (sfi *ServiceFileIndex) GetIndexHeader() string
- type ServiceMap
- type ServiceStateController
- type ShellConfig
- type SnapshotConfig
- type Total
- type UnknownElasticStructError
Constants ¶
const ( DefaultHomeDir = "/opt/serviced" DefaultRPCPort = 4979 )
Variables ¶
This section is empty.
Functions ¶
func GetAgentIP ¶
GetAgentIP returns the agent ip address
func GetDefaultOptions ¶
func GetDefaultOptions(cfg utils.ConfigReader) config.Options
func GetOptionsAgent ¶
func GetOptionsAgent() bool
GetOptionsAgent returns the agent mode setting from options
func GetOptionsMaster ¶
func GetOptionsMaster() bool
GetOptionsMaster returns the master mode setting from options
func GetOptionsMasterPoolID ¶
func GetOptionsMasterPoolID() string
GetOptionsMasterPoolID returns the master pool ID from options
func GetOptionsMaxRPCClients ¶
func GetOptionsMaxRPCClients() int
GetOptionsMaxRPCClients returns the max RPC clients setting from options
func GetOptionsRPCEndpoint ¶
func GetOptionsRPCEndpoint() string
GetOptionsRPCEndpoint returns the serviced RPC endpoint from options
func GetOptionsRPCPort ¶
func GetOptionsRPCPort() string
GetOptionsRPCPort returns the serviced RPC port from options
func IDsToString ¶
func IDsToString(ids interface{}) string
func NormalizeYYYYMMDD ¶
NormalizeYYYYMMDD matches optional non-digits, 4 digits, optional non-digits, 2 digits, optional non-digits, 2 digits, optional non-digits Returns those 8 digits formatted as "dddd.dd.dd", or error if unparseable.
func ValidateCommonOptions ¶
Validate options which are common to all CLI commands
func ValidateServerOptions ¶
Validate options which are specific to running as a server
Types ¶
type API ¶
type API interface { // Server StartServer() error ServicedHealthCheck(IServiceNames []string) ([]isvcs.IServiceHealthResult, error) // Hosts GetHosts() ([]host.Host, error) GetHost(string) (*host.Host, error) GetHostMap() (map[string]host.Host, error) AddHost(HostConfig) (*host.Host, []byte, error) AddHostPrivate(HostConfig) (*host.Host, []byte, error) RemoveHost(string) error GetHostMemory(string) (*metrics.MemoryUsageStats, error) SetHostMemory(HostUpdateConfig) error GetHostPublicKey(string) ([]byte, error) RegisterHost([]byte) error RegisterRemoteHost(*host.Host, utils.URL, []byte, bool) error WriteDelegateKey(string, []byte) error AuthenticateHost(string) (string, int64, error) ResetHostKey(string) ([]byte, error) GetHostWithAuthInfo(string) (*AuthHost, error) GetHostsWithAuthInfo() ([]AuthHost, error) // Pools GetResourcePools() ([]pool.ResourcePool, error) GetResourcePool(string) (*pool.ResourcePool, error) AddResourcePool(PoolConfig) (*pool.ResourcePool, error) RemoveResourcePool(string) error UpdateResourcePool(pool pool.ResourcePool) error GetPoolIPs(string) (*pool.PoolIPs, error) AddVirtualIP(pool.VirtualIP) error RemoveVirtualIP(pool.VirtualIP) error // Services GetAllServiceDetails() ([]service.ServiceDetails, error) GetServiceDetails(serviceID string) (*service.ServiceDetails, error) GetServiceStatus(string) (map[string]map[string]interface{}, error) GetService(string) (*service.Service, error) AddService(ServiceConfig) (*service.ServiceDetails, error) CloneService(string, string) (*service.ServiceDetails, error) RemoveService(string) error UpdateService(io.Reader) (*service.ServiceDetails, error) UpdateServiceObj(service.Service) (*service.ServiceDetails, error) StartService(SchedulerConfig) (int, error) RestartService(SchedulerConfig) (int, error) RebalanceService(SchedulerConfig) (int, error) StopService(SchedulerConfig) (int, error) PauseService(SchedulerConfig) (int, error) AssignIP(IPConfig) error GetEndpoints(serviceID string, reportImports, reportExports, validate bool) ([]applicationendpoint.EndpointReport, error) ResolveServicePath(path string, noprefix bool) ([]service.ServiceDetails, error) ClearEmergency(serviceID string) (int, error) RemoveIP(args []string) error SetIP(IPConfig) error // Shell StartShell(ShellConfig) error RunShell(ShellConfig, chan struct{}) (int, error) // Snapshots GetSnapshots() ([]dao.SnapshotInfo, error) GetSnapshotsByServiceID(string) ([]dao.SnapshotInfo, error) GetSnapshotByServiceIDAndTag(string, string) (string, error) AddSnapshot(SnapshotConfig) (string, error) RemoveSnapshot(string) error Rollback(string, bool) error TagSnapshot(string, string) error RemoveSnapshotTag(string, string) (string, error) // Templates GetServiceTemplates() ([]template.ServiceTemplate, error) GetServiceTemplate(string) (*template.ServiceTemplate, error) AddServiceTemplate(io.Reader) (*template.ServiceTemplate, error) RemoveServiceTemplate(string) error CompileServiceTemplate(CompileTemplateConfig) (*template.ServiceTemplate, error) DeployServiceTemplate(DeployTemplateConfig) ([]service.ServiceDetails, error) // Backup & Restore GetBackupEstimate(string, []string) (*dao.BackupEstimate, error) Backup(string, []string, bool) (string, error) Restore(string) error // Docker ResetRegistry() error RegistrySync() error UpgradeRegistry(endpoint string, override bool) error DockerOverride(newImage string, oldImage string) error // Logs ExportLogs(config ExportLogsConfig) error // Metric PostMetric(metricName string, metricValue string) (string, error) // Scripts ScriptRun(fileName string, config *script.Config, stopChan chan struct{}) error ScriptParse(fileName string, config *script.Config) error // Volumes GetVolumeStatus() (*volume.Statuses, error) // Public endpoints AddPublicEndpointPort(serviceid, endpointName, portAddr string, usetls bool, protocol string, isEnabled, restart bool) (*servicedefinition.Port, error) RemovePublicEndpointPort(serviceid, endpointName, portAddr string) error EnablePublicEndpointPort(serviceid, endpointName, portAddr string, isEnabled bool) error AddPublicEndpointVHost(serviceid, endpointName, vhost string, isEnabled, restart bool) (*servicedefinition.VHost, error) RemovePublicEndpointVHost(serviceid, endpointName, vhost string) error EnablePublicEndpointVHost(serviceid, endpointName, vhost string, isEnabled bool) error GetAllPublicEndpoints() ([]service.PublicEndpoint, error) // Service Instances GetServiceInstances(serviceID string) ([]service.Instance, error) StopServiceInstance(serviceID string, instanceID int) error AttachServiceInstance(serviceID string, instanceID int, command string, args []string) error LogsForServiceInstance(serviceID string, instanceID int, command string, args []string) error SendDockerAction(serviceID string, instanceID int, action string, args []string) error // Debug Management DebugEnableMetrics() (string, error) DebugDisableMetrics() (string, error) }
API is the intermediary between the command-line interface and the dao layer
func NewAPI ¶
func NewAPI(master master.ClientInterface, agent *agent.Client, docker *dockerclient.Client, dao dao.ControlPlane) API
New creates a new API type
type CompileTemplateConfig ¶
CompileTemplateConfig is the configuration object to conpile a template directory
type ContainerFileIndex ¶
type ContainerFileIndex struct {
// contains filtered or unexported fields
}
ContainerFileIndex maintains an index of separate files based on each unique combination of container ID and application log file name. Depending on the lifespan of the container and the date range defined by exporter.days, some of the files created by this method may have messages from multiple dates.
func NewContainerFileIndex ¶
func NewContainerFileIndex() *ContainerFileIndex
func (*ContainerFileIndex) AddIndexForMessage ¶
func (cfi *ContainerFileIndex) AddIndexForMessage(index int, message *parsedMessage)
func (*ContainerFileIndex) FindIndexForMessage ¶
func (cfi *ContainerFileIndex) FindIndexForMessage(message *parsedMessage) (index int, found bool)
func (*ContainerFileIndex) GetFileIndexData ¶
func (cfi *ContainerFileIndex) GetFileIndexData(index int, outputFile outputFileInfo, hostName, serviceName string) string
func (*ContainerFileIndex) GetFileName ¶
func (cfi *ContainerFileIndex) GetFileName(index int, message *parsedMessage) string
func (*ContainerFileIndex) GetIndexHeader ¶
func (cfi *ContainerFileIndex) GetIndexHeader() string
type DateFileIndex ¶
type DateFileIndex struct {
// contains filtered or unexported fields
}
DateFileIndex maintains an index of separate files based on date. Therefore, a single output file will contain messages from multiple services.
func NewDateFileIndex ¶
func NewDateFileIndex() *DateFileIndex
func (*DateFileIndex) AddIndexForMessage ¶
func (dfi *DateFileIndex) AddIndexForMessage(index int, message *parsedMessage)
func (*DateFileIndex) FindIndexForMessage ¶
func (dfi *DateFileIndex) FindIndexForMessage(message *parsedMessage) (index int, found bool)
func (*DateFileIndex) GetFileIndexData ¶
func (dfi *DateFileIndex) GetFileIndexData(index int, outputFile outputFileInfo, hostName, serviceName string) string
func (*DateFileIndex) GetFileName ¶
func (dfi *DateFileIndex) GetFileName(index int, message *parsedMessage) string
func (*DateFileIndex) GetIndexHeader ¶
func (dfi *DateFileIndex) GetIndexHeader() string
type DeployTemplateConfig ¶
type DeployTemplateConfig struct { ID string PoolID string DeploymentID string ManualAssignIPs bool }
DeployTemplateConfig is the configuration object to deploy a template
type ElasticSearchResults ¶
type ExportGroup ¶
type ExportGroup int
The export process produces 1 or more <nnn>.log files containing the exported log messages. The values of ExportGroup control which messages are grouped together in a single <nnn>.log file:
GroupByContainer Each <nnn>.log contains messages for the same unique combination of container ID and application log file name. GroupByDay Each <nnn>.log contains messages for the same calendar day. GroupByService Each <nnn>.log contains messages for the same logical service.
const ( GroupByContainerID ExportGroup = iota GroupByDay GroupByService )
func ExportGroupFromString ¶
func ExportGroupFromString(value string) ExportGroup
func (ExportGroup) String ¶
func (eg ExportGroup) String() string
type ExportLogDriver ¶
type ExportLogDriver interface { // Sets the ES Logstash connection info; logstashES should be in the format hostname:port SetLogstashInfo(logstashES string) error // Returns a list of all the dates for which logs are available // The strings are in YYYY.MM.DD format, and in reverse chronological order. LogstashDays() ([]string, error) // Start a new search of ES logstash for a given date StartSearch(logstashIndex string, query string) (ElasticSearchResults, error) // Scroll to the next set of search results ScrollSearch(scrollID string) (ElasticSearchResults, error) }
This interface is primarily provided for unit-testing ExportLogs(). Admittedly a very leaky abstraction around only a handful of elastigo calls. A better implementation would be to design an interface around all of the elastigo APIs which are needed by ExportLogs and the datastore package. Alternatively, maybe we need create a package just for interfacing withES Logstash. Either way that effort is outside the scope of making ExportLogs() testable.
type ExportLogDriverMock ¶
func (*ExportLogDriverMock) LogstashDays ¶
func (_m *ExportLogDriverMock) LogstashDays() ([]string, error)
func (*ExportLogDriverMock) ScrollSearch ¶
func (_m *ExportLogDriverMock) ScrollSearch(scrollID string) (ElasticSearchResults, error)
func (*ExportLogDriverMock) SetLogstashInfo ¶
func (_m *ExportLogDriverMock) SetLogstashInfo(logstashES string) error
func (*ExportLogDriverMock) StartSearch ¶
func (_m *ExportLogDriverMock) StartSearch(logstashIndex string, query string) (ElasticSearchResults, error)
type ExportLogsConfig ¶
type ExportLogsConfig struct { // A list of one or more serviced IDs to export logs for // (includes all child services unless ExcludeChildren is true) ServiceIDs []string // A list of one or more application log file names to export FileNames []string // In the format yyyy.mm.dd (inclusive), "" means unbounded FromDate string // In the format yyyy.mm.dd (inclusive), "" means unbounded ToDate string // Name of the compressed tar file containing all of the exported logs. If not specified, defaults to // "./serviced-log-export-<TIMESTAMP>.tgz" where <TIMESTAMP> is an RFC3339-like string (e.g. 2016-06-02T143843Z) OutFileName string // Set to true to default more verbose logging Debug bool // Defines which messages are grouped together in each output file GroupBy ExportGroup // Set to true to exclude child services ExcludeChildren bool // Driver to work with logstash ES instance; if nil a default driver will be used. Primarily used for testing. Driver ExportLogDriver // contains filtered or unexported fields }
ExportLogsConfig is the deserialized object from the command-line
type ExternalHit ¶
type ExternalHit struct { Total Total `json:"total"` MaxScore float64 `json:"max_score"` Hits []InternalHit `json:"hits,omitempty"` }
type FileIndex ¶
type FileIndex interface { FindIndexForMessage(message *parsedMessage) (index int, found bool) AddIndexForMessage(index int, message *parsedMessage) GetFileIndexData(index int, outputFile outputFileInfo, hostName, serviceName string) string GetIndexHeader() string GetFileName(index int, message *parsedMessage) string }
func NewFileIndex ¶
func NewFileIndex(groupBy ExportGroup) FileIndex
type HostConfig ¶
type HostConfig struct { Address *utils.URL Nat *utils.URL PoolID string Memory string IPs []string }
HostConfig is the deserialized object from the command-line
type HostUpdateConfig ¶
type IPConfig ¶
type IPConfig struct { ServiceID string IPAddress string Port uint16 Proto string EndpointName string }
IPConfig is the deserialized object from the command-line
type ImageMap ¶
ImageMap parses docker image data
type InternalHit ¶
type InternalHit struct { Index string `json:"_index"` Type string `json:"_type"` Id string `json:"_id"` Version int `json:"_version,omitempty"` PrimaryTerm int `json:"_primary_term,omitempty"` SeqNo int `json:"_seq_no,omitempty"` Score float64 `json:"_score"` Source *json.RawMessage `json:"_source"` }
type PoolConfig ¶
type PoolConfig struct { PoolID string Realm string CoreLimit int MemoryLimit uint64 Permissions pool.Permission }
PoolConfig is the deserialized data from the command-line
type PortMap ¶
type PortMap map[string]servicedefinition.EndpointDefinition
PortMap parses remote and local port data from the command line
type SchedulerConfig ¶
type ServiceConfig ¶
type ServiceConfig struct { Name string ParentServiceID string ImageID string Command string LocalPorts *PortMap RemotePorts *PortMap }
ServiceConfig is the deserialized object from the command-line
type ServiceFileIndex ¶
type ServiceFileIndex struct {
// contains filtered or unexported fields
}
ServiceFileIndex maintains an index of separate files based on service id. Therefore, a single output file will contain messages for all instances of single service.
func NewServiceFileIndex ¶
func NewServiceFileIndex() *ServiceFileIndex
func (*ServiceFileIndex) AddIndexForMessage ¶
func (sfi *ServiceFileIndex) AddIndexForMessage(index int, message *parsedMessage)
func (*ServiceFileIndex) FindIndexForMessage ¶
func (sfi *ServiceFileIndex) FindIndexForMessage(message *parsedMessage) (index int, found bool)
func (*ServiceFileIndex) GetFileIndexData ¶
func (sfi *ServiceFileIndex) GetFileIndexData(index int, outputFile outputFileInfo, hostName, serviceName string) string
func (*ServiceFileIndex) GetFileName ¶
func (sfi *ServiceFileIndex) GetFileName(index int, message *parsedMessage) string
func (*ServiceFileIndex) GetIndexHeader ¶
func (sfi *ServiceFileIndex) GetIndexHeader() string
type ServiceMap ¶
type ServiceMap map[string]service.ServiceDetails
ServiceMap maps services by its service id
func NewServiceMap ¶
func NewServiceMap(services []service.ServiceDetails) ServiceMap
NewServiceMap creates a new service map from a slice of services
func (ServiceMap) Add ¶
func (m ServiceMap) Add(service service.ServiceDetails) error
Add appends a service to the service map
func (ServiceMap) Get ¶
func (m ServiceMap) Get(serviceID string) service.ServiceDetails
Get gets a service from the service map identified by its service id
func (ServiceMap) Remove ¶
func (m ServiceMap) Remove(serviceID string) error
Remove removes a service from the service map
func (ServiceMap) Tree ¶
func (m ServiceMap) Tree() map[string][]string
Tree returns a map of parent services and its list of children
func (ServiceMap) Update ¶
func (m ServiceMap) Update(service service.ServiceDetails)
Update updates an existing service within the ServiceMap. If the service not exist, it gets created.
type ServiceStateController ¶
type ServiceStateController func(SchedulerConfig) (int, error)
Type of method that controls the state of a service
type ShellConfig ¶
type ShellConfig struct { ServiceID string Command string Args []string Username string SaveAs string IsTTY bool Mounts []string ServicedEndpoint string LogToStderr bool LogStash struct { Enable bool SettleTime string } }
ShellConfig is the deserialized object from the command-line
type SnapshotConfig ¶
type UnknownElasticStructError ¶
func (*UnknownElasticStructError) Error ¶
func (e *UnknownElasticStructError) Error() string
Source Files ¶
- api.go
- backup.go
- daemon.go
- daemon_linux.go
- debug.go
- docker.go
- elastigologdriver.go
- exportlogdriver.go
- healthcheck.go
- host.go
- imagemap.go
- instance.go
- interfaces.go
- logs.go
- metric.go
- options.go
- pool.go
- portmap.go
- publicendpoint.go
- script.go
- service.go
- servicemap.go
- shell.go
- snapshot.go
- storageoptions.go
- template.go
- utils.go
- volume.go