service

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package service defines the interface that fleetspeak client side services must implement, along with some related types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AckMessage

type AckMessage struct {
	M   *fspb.Message
	Ack func()
}

AckMessage is a message that can be acknowledged. If no acknowledgement is required, Ack may be nil.

type Context

type Context interface {
	// Send provides a message to the Fleetspeak system for delivery to the server or to other
	// Fleetspeak services running on the local client.
	Send(context.Context, AckMessage) error

	// GetLocalInfo returns information about the local client.
	GetLocalInfo() *LocalInfo

	// GetFileIfModified attempts to retrieve a file from the server, if it been modified since
	// modSince. Return values follow the semantics of Communicator.GetFileIfModified.
	GetFileIfModified(ctx context.Context, name string, modSince time.Time) (data io.ReadCloser, mod time.Time, err error)

	// StatsCollector returns the stats.Collector used by the Fleetspeak client.
	Stats() stats.Collector
}

A Context encapsulates the functionality that the Fleetspeak client installation provides to a configured service.

type Factory

type Factory func(conf *fspb.ClientServiceConfig) (Service, error)

A Factory creates a Service according to a provided configuration.

type LocalInfo

type LocalInfo struct {
	ClientID common.ClientID // The ClientID of the local client.
	Labels   []*fspb.Label   // The client labels (ServiceName="client") set on the local client.
	Services []string        // The Fleetspeak services currently configured on the local client.
}

LocalInfo stores summary information about the local client.

type Service

type Service interface {
	// Start performs any necessary setup for the Service.
	//
	// If it returns nil Fleetspeak will assume that the service is ready to
	// process messages. Otherwise Fleetspeak will consider the service
	// unavailable.
	Start(Context) error

	// ProcessMessage processes one message.
	//
	// If it returns nil, Fleetspeak will acknowledge the message and it
	// will be marked as successfully processed. If it returns an error, the
	// message will be marked as failed.
	//
	// Note however that in either case, the delivery of the acknowledgement
	// is not guaranteed and there is a chance that the message will be sent
	// again.
	ProcessMessage(context.Context, *fspb.Message) error

	// Stop shuts down the service in an orderly manner.
	Stop() error
}

A Service represents a configured client component which can accept and send messages via Fleetspeak.

func NOOPFactory

func NOOPFactory(conf *fspb.ClientServiceConfig) (Service, error)

NOOPFactory is a Factory which produces a service that does nothing. It accepts any message without processing it, and produces no messages for the server.

Jump to

Keyboard shortcuts

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