agent

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Results

func Results() <-chan []*probe.Result

Results returns the default channel of probe results to receive from.

func ScheduleProbe

func ScheduleProbe(label string, configuration map[string]interface{}, probeConfiguration, check string, interval time.Duration)

ScheduleProbe adds a probe to the default `Scheduler` to be fired every `interval`.

Types

type Client

type Client struct {
	api.PantoClient

	Organization string
	Agent        string
	// contains filtered or unexported fields
}

Client is the main structure for a Panto agent to connect to a Panto server and perform requests. It embeds a gRPC client for the Panto service, as defined in the proto files.

func NewClient

func NewClient(conf ClientConfiguration) (*Client, error)

NewClient creates a gRPC client according to configuration and connects it to the server.

func (*Client) Close

func (c *Client) Close()

Close disconnect the gRPC client from the server

func (*Client) ReportResults

func (c *Client) ReportResults(results []*probe.Result) (string, error)

ReportResults sends the result of a probe to the server it returns the configuration version and a (possible) error.

func (*Client) RequestConfiguration

func (c *Client) RequestConfiguration() (res *api.ListProbeConfigurationsResponse, agentVersion string, err error)

RequestConfiguration sends a request for the agent's configuration to the server

type ClientConfiguration

type ClientConfiguration struct {
	Address           string
	AgentName         string
	CertFilePath      string
	NoTLS             bool
	Timeout           time.Duration
	ConfigurationDump string
}

ClientConfiguration contains all configuration parameters to instantiate and connect a `Client`.

func (*ClientConfiguration) GetRequestMetadata

func (c *ClientConfiguration) GetRequestMetadata(context.Context, ...string) (map[string]string, error)

GetRequestMetadata creates the gRPC request metadata from the client configuration.

func (*ClientConfiguration) RequireTransportSecurity

func (c *ClientConfiguration) RequireTransportSecurity() bool

RequireTransportSecurity indicates whether the credentials requires transport security

type DumpedConfiguration

type DumpedConfiguration struct {
	Version              string                               `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
	Configurations       *api.ListProbeConfigurationsResponse `protobuf:"bytes,2,opt,name=Configurations,proto3" json:"Configurations,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                             `json:"-"`
	XXX_unrecognized     []byte                               `json:"-"`
	XXX_sizecache        int32                                `json:"-"`
}

DumpedConfiguration defines the representation of the backup file for the agent configuration

func (*DumpedConfiguration) Descriptor

func (*DumpedConfiguration) Descriptor() ([]byte, []int)

func (*DumpedConfiguration) GetConfigurations

func (*DumpedConfiguration) GetVersion

func (m *DumpedConfiguration) GetVersion() string

func (*DumpedConfiguration) ProtoMessage

func (*DumpedConfiguration) ProtoMessage()

func (*DumpedConfiguration) Reset

func (m *DumpedConfiguration) Reset()

func (*DumpedConfiguration) String

func (m *DumpedConfiguration) String() string

func (*DumpedConfiguration) XXX_DiscardUnknown

func (m *DumpedConfiguration) XXX_DiscardUnknown()

func (*DumpedConfiguration) XXX_Marshal

func (m *DumpedConfiguration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DumpedConfiguration) XXX_Merge

func (m *DumpedConfiguration) XXX_Merge(src proto.Message)

func (*DumpedConfiguration) XXX_Size

func (m *DumpedConfiguration) XXX_Size() int

func (*DumpedConfiguration) XXX_Unmarshal

func (m *DumpedConfiguration) XXX_Unmarshal(b []byte) error

type DumpedSpooler added in v0.5.0

type DumpedSpooler struct {
	Results              []*api.Result `protobuf:"bytes,1,rep,name=Results,proto3" json:"Results,omitempty"`
	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
	XXX_unrecognized     []byte        `json:"-"`
	XXX_sizecache        int32         `json:"-"`
}

DumpedSpooler defines the representation of the backup file for the agent spooler

func (*DumpedSpooler) Descriptor added in v0.5.0

func (*DumpedSpooler) Descriptor() ([]byte, []int)

func (*DumpedSpooler) GetResults added in v0.5.0

func (m *DumpedSpooler) GetResults() []*api.Result

func (*DumpedSpooler) ProtoMessage added in v0.5.0

func (*DumpedSpooler) ProtoMessage()

func (*DumpedSpooler) Reset added in v0.5.0

func (m *DumpedSpooler) Reset()

func (*DumpedSpooler) String added in v0.5.0

func (m *DumpedSpooler) String() string

func (*DumpedSpooler) XXX_DiscardUnknown added in v0.5.0

func (m *DumpedSpooler) XXX_DiscardUnknown()

func (*DumpedSpooler) XXX_Marshal added in v0.5.0

func (m *DumpedSpooler) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DumpedSpooler) XXX_Merge added in v0.5.0

func (m *DumpedSpooler) XXX_Merge(src proto.Message)

func (*DumpedSpooler) XXX_Size added in v0.5.0

func (m *DumpedSpooler) XXX_Size() int

func (*DumpedSpooler) XXX_Unmarshal added in v0.5.0

func (m *DumpedSpooler) XXX_Unmarshal(b []byte) error

type Scheduler

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

Scheduler is a probe scheduling engine. It contains a list of currently scheduled probes and handles executing probes at regular intervals.

var DefaultScheduler *Scheduler

DefaultScheduler is a default scheduler, instantiated by the package for usage by the easy interface (package-level functions).

func NewScheduler

func NewScheduler() *Scheduler

NewScheduler creates and returns a new `Scheduler` instance.

func (*Scheduler) AddProbe

func (s *Scheduler) AddProbe(label string, configuration map[string]interface{}, probeConfiguration, check string, interval time.Duration)

AddProbe schedules a probe to be fired every `interval`. It returns a function to be called to terminate the probe

func (*Scheduler) ConfigureScheduler

func (s *Scheduler) ConfigureScheduler(c *api.ListProbeConfigurationsResponse, v string) error

ConfigureScheduler loads the api.ListProbeConfigurationsResponse in the Scheduler

func (*Scheduler) GetProbes

func (s *Scheduler) GetProbes() []string

GetProbes returns a copy of the Scheduler's ProbeConfiguration names. To avoid a race condition, the results are copied in the same goroutine as the add & remove critical operations and returned to the current context via a channel. Both copying and async introduce a latency & memory overhead. Use this method with that in mind.

func (Scheduler) GetVersion

func (s Scheduler) GetVersion() string

GetVersion returns the version of the configuration in the Scheduler

func (*Scheduler) RemoveAllProbes

func (s *Scheduler) RemoveAllProbes() error

RemoveAllProbes flushes the current Scheduler from all the runningProbes

func (*Scheduler) Results

func (s *Scheduler) Results() <-chan []*probe.Result

Results returns a channel of probe results to receive from.

func (*Scheduler) Run

func (s *Scheduler) Run()

Run starts the scheduler. This function does not return, it is safe to run in a goroutine.

func (*Scheduler) SetVersion

func (s *Scheduler) SetVersion(version string) error

SetVersion stores the version of the configuration in the Scheduler

func (Scheduler) String

func (s Scheduler) String() string

type Spooler

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

Spooler is used to spool data from a failed report, to try again when connectivity is re-established

func NewSpooler

func NewSpooler(capacity int, path string) (*Spooler, error)

NewSpooler creates and returns a Spooler that can store up to maxResults. maxResults is the maximum number of results spooled. Once the maximum is reached, the spooler evicts the oldest results.

func (*Spooler) AddResults

func (s *Spooler) AddResults(results []*probe.Result)

AddResults adds a batch of results to the Spooler. If the Spooler reaches max capacity, the oldest results are evicted.

func (*Spooler) Clear

func (s *Spooler) Clear()

Clear clears all results from the Spooler.

func (Spooler) Count

func (s Spooler) Count() int

Count returns the number of items currently in the Spooler.

func (Spooler) Results

func (s Spooler) Results() []*probe.Result

Results returns the spooled results as an array.

Directories

Path Synopsis
Package probe contains everything to register, schedule and run probes, as well as the default set of probes bundled into Panto <TODO> Conceptual documentation about the scheduler <TODO> Conceptual documentation about the registry
Package probe contains everything to register, schedule and run probes, as well as the default set of probes bundled into Panto <TODO> Conceptual documentation about the scheduler <TODO> Conceptual documentation about the registry

Jump to

Keyboard shortcuts

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