worker

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: GPL-3.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelRxFunc

type CancelRxFunc func(w *Worker, addr string, id string, cancelID string) error

CancelRxFunc is a function type that gets called each time the worker receives a cancel message

type EventHandlerFunc

type EventHandlerFunc func(e ipc.DispatcherEvent)

EventHandlerFunc is a function type that gets called each time the worker receives a com.redhat.Yggdrasil1.Dispatcher1.Event signal.

type RxFunc

type RxFunc func(w *Worker, addr string, id string, responseTo string, metadata map[string]string, data []byte) error

RxFunc is a function type that gets called each time the worker receives data.

type Worker

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

Worker implements the com.redhat.Yggdrasil1.Worker1 interface.

func NewWorker

func NewWorker(
	directive string,
	remoteContent bool,
	features map[string]string,
	cancel CancelRxFunc,
	rx RxFunc,
	events EventHandlerFunc,
) (*Worker, error)

NewWorker creates a new worker.

func (*Worker) Connect

func (w *Worker) Connect(quit <-chan os.Signal) error

Connect connects to the bus, exports the worker on its object path, and requests a well-known bus name. It connects to a private session bus, if DBUS_SESSION_BUS_ADDRESS is set in the environment. Otherwise it connects to the system bus. It exports w onto the bus and waits until a signal is received on quit.

func (*Worker) EmitEvent

func (w *Worker) EmitEvent(
	event ipc.WorkerEventName,
	messageID string,
	responseTo string,
	data map[string]string,
) error

EmitEvent emits a WorkerEvent, worker message id, and key-value pairs of optional data.

func (*Worker) GetFeature

func (w *Worker) GetFeature(name string) string

GetFeature retrieves the value from the feature map for given key.

func (*Worker) SetFeature

func (w *Worker) SetFeature(name, value string) error

SetFeature sets the value for the given key in the feature map and emits the PropertiesChanged signal.

func (*Worker) Transmit

func (w *Worker) Transmit(
	addr string,
	id string,
	responseTo string,
	metadata map[string]string,
	data []byte,
) (responseCode int, responseMetadata map[string]string, responseData []byte, err error)

Transmit wraps a com.redhat.Yggdrasil1.Dispatcher1.Transmit method call for ease of use from the worker.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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