{"modulePath":"github.com/AliceO2Group/Control","version":"v1.51.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package event\n\nPackage event provides event publishing and streaming functionality for O² Control components, supporting Kafka and dummy event writers.\n\n## Variables\n\n```go\nvar (\n\tKAFKAWRITER  = \"kafka_writer\"\n\tKAFKAPREPARE = \"kafka_prepare\"\n)\n```\n\n## Types\n\n```go\ntype AgentFailedEvent struct {\n\tAgentId mesos.AgentID `json:\"agentId\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewAgentFailedEvent(agentId *mesos.AgentID) *AgentFailedEvent\n```\n\n```go\nfunc (e *AgentFailedEvent) GetId() mesos.AgentID\n```\n\n```go\nfunc (e *AgentFailedEvent) GetLabels() map[string]string\n```\n\n```go\nfunc (e *AgentFailedEvent) GetName() string\n```\n\n```go\nfunc (e *AgentFailedEvent) GetTimestamp() string\n```\n\n```go\nfunc (e *AgentFailedEvent) SetLabels(labels map[string]string)\n```\n\n```go\ntype AnnounceTaskPIDEvent struct {\n\tTaskId string `json:\"taskId\"`\n\tPID    int32  `json:\"pid\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewAnnounceTaskPIDEvent(id string, pid int32) (e *AnnounceTaskPIDEvent)\n```\n\n```go\nfunc (e *AnnounceTaskPIDEvent) GetLabels() map[string]string\n```\n\n```go\nfunc (e *AnnounceTaskPIDEvent) GetName() string\n```\n\n```go\nfunc (e *AnnounceTaskPIDEvent) GetTaskId() string\n```\n\n```go\nfunc (e *AnnounceTaskPIDEvent) GetTaskPID() int\n```\n\n```go\nfunc (e *AnnounceTaskPIDEvent) GetTimestamp() string\n```\n\n```go\nfunc (e *AnnounceTaskPIDEvent) SetLabels(labels map[string]string)\n```\n\n```go\ntype BasicTaskTerminated struct {\n\tDeviceEventBase\n\tExitCode             int             `json:\"exitCode\"`\n\tStdout               string          `json:\"stdout\"`\n\tStderr               string          `json:\"stderr\"`\n\tVoluntaryTermination bool            `json:\"voluntaryTermination\"`\n\tFinalMesosState      mesos.TaskState `json:\"finalMesosState\"`\n}\n```\n\n```go\nfunc (e *BasicTaskTerminated) GetLabels() map[string]string\n```\n\n```go\nfunc (e *BasicTaskTerminated) GetName() string\n```\n\n```go\nfunc (e *BasicTaskTerminated) GetTimestamp() string\n```\n\n```go\nfunc (e *BasicTaskTerminated) SetLabels(labels map[string]string)\n```\n\n```go\ntype DeviceEvent interface {\n\tEvent\n\tGetOrigin() DeviceEventOrigin\n\tGetType() pb.DeviceEventType\n}\n```\n\n```go\nfunc NewDeviceEvent(origin DeviceEventOrigin, t pb.DeviceEventType) (de DeviceEvent)\n```\n\n```go\ntype DeviceEventBase struct {\n\tType   pb.DeviceEventType `json:\"type\"`\n\tOrigin DeviceEventOrigin  `json:\"origin\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (e *DeviceEventBase) GetLabels() map[string]string\n```\n\n```go\nfunc (b *DeviceEventBase) GetOrigin() DeviceEventOrigin\n```\n\n```go\nfunc (e *DeviceEventBase) GetTimestamp() string\n```\n\n```go\nfunc (b *DeviceEventBase) GetType() pb.DeviceEventType\n```\n\n```go\nfunc (e *DeviceEventBase) SetLabels(labels map[string]string)\n```\n\n```go\ntype DeviceEventOrigin struct {\n\t// FIXME: replace these Mesos-tainted string wrappers with plain strings\n\tAgentId    mesos.AgentID    `json:\"agentId\"`\n\tExecutorId mesos.ExecutorID `json:\"executorId\"`\n\tTaskId     mesos.TaskID     `json:\"taskId\"`\n}\n```\n\n```go\ntype DummyReader struct{}\n```\nDummyReader is an implementation of Reader that returns no events.\n\n```go\nfunc (*DummyReader) Close() error\n```\n\n```go\nfunc (*DummyReader) Last(context.Context) (*pb.Event, error)\n```\n\n```go\nfunc (*DummyReader) Next(context.Context) (*pb.Event, error)\n```\n\n```go\ntype DummyWriter struct{}\n```\n\n```go\nfunc (*DummyWriter) Close()\n```\n\n```go\nfunc (*DummyWriter) WriteEvent(interface{})\n```\n\n```go\nfunc (*DummyWriter) WriteEventWithTimestamp(interface{}, time.Time)\n```\n\n```go\ntype EndOfStream struct {\n\tDeviceEventBase\n}\n```\n\n```go\nfunc (e *EndOfStream) GetLabels() map[string]string\n```\n\n```go\nfunc (e *EndOfStream) GetName() string\n```\n\n```go\nfunc (e *EndOfStream) GetTimestamp() string\n```\n\n```go\nfunc (e *EndOfStream) SetLabels(labels map[string]string)\n```\n\n```go\ntype EnvironmentEvent struct {\n\tEnvironmentID string\n\tRun           uint32\n\tState         string\n\tError         error\n\tMessage       string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (e *EnvironmentEvent) GetError() string\n```\n\n```go\nfunc (e *EnvironmentEvent) GetLabels() map[string]string\n```\n\n```go\nfunc (e *EnvironmentEvent) GetMessage() string\n```\n\n```go\nfunc (e *EnvironmentEvent) GetName() string\n```\n\n```go\nfunc (e *EnvironmentEvent) GetRun() uint32\n```\n\n```go\nfunc (e *EnvironmentEvent) GetState() string\n```\n\n```go\nfunc (e *EnvironmentEvent) GetTimestamp() string\n```\n\n```go\nfunc (e *EnvironmentEvent) SetLabels(labels map[string]string)\n```\n\n```go\ntype Event interface {\n\tGetName() string\n\tGetTimestamp() string\n\tGetLabels() map[string]string\n\tSetLabels(map[string]string)\n}\n```\n\n```go\ntype ExecutorFailedEvent struct {\n\tExecutorId mesos.ExecutorID `json:\"executorId\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewExecutorFailedEvent(executorId *mesos.ExecutorID) *ExecutorFailedEvent\n```\n\n```go\nfunc (e *ExecutorFailedEvent) GetId() mesos.ExecutorID\n```\n\n```go\nfunc (e *ExecutorFailedEvent) GetLabels() map[string]string\n```\n\n```go\nfunc (e *ExecutorFailedEvent) GetName() string\n```\n\n```go\nfunc (e *ExecutorFailedEvent) GetTimestamp() string\n```\n\n```go\nfunc (e *ExecutorFailedEvent) SetLabels(labels map[string]string)\n```\n\n```go\ntype FifoBuffer[T any] struct {\n\t// contains filtered or unexported fields\n}\n```\nThis structure is meant to be used as a threadsafe FIFO with builtin waiting for new data in its Pop and PopMultiple functions. It is meant to be used with multiple goroutines, it is a waste of synchronization mechanisms if used synchronously.\n\n```go\nfunc NewFifoBuffer[T any]() (result FifoBuffer[T])\n```\n\n```go\nfunc (this *FifoBuffer[T]) Length() int\n```\n\n```go\nfunc (this *FifoBuffer[T]) PopMultiple(numberToPop uint) (result []T)\n```\nBlocks until it has some value in internal buffer\n\n```go\nfunc (this *FifoBuffer[T]) Push(value T)\n```\n\n```go\nfunc (this *FifoBuffer[T]) ReleaseGoroutines()\n```\n\n```go\ntype HasEnvID interface {\n\tGetEnvironmentId() string\n}\n```\n\n```go\ntype IntegratedServiceEvent interface {\n\tEvent\n\tGetServiceName() string\n}\n```\n\n```go\ntype IntegratedServiceEventBase struct {\n\tServiceName string `json:\"serviceName\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (e *IntegratedServiceEventBase) GetLabels() map[string]string\n```\n\n```go\nfunc (b *IntegratedServiceEventBase) GetServiceName() string\n```\n\n```go\nfunc (e *IntegratedServiceEventBase) GetTimestamp() string\n```\n\n```go\nfunc (e *IntegratedServiceEventBase) SetLabels(labels map[string]string)\n```\n\n```go\ntype KafkaReader struct {\n\t*kafka.Reader\n\t// contains filtered or unexported fields\n}\n```\nKafkaReader reads events from Kafka and provides a blocking, cancellable API to fetch events.\n\n```go\nfunc NewReaderWithTopic(topic topic.Topic, groupID string) *KafkaReader\n```\nNewReaderWithTopic creates a KafkaReader for the provided topic and starts it.\n\n```go\nfunc (r *KafkaReader) Close() error\n```\nClose stops the reader.\n\n```go\nfunc (r *KafkaReader) Last(ctx context.Context) (*pb.Event, error)\n```\nLast fetches the last available message on the topic (considering all partitions). If multiple partitions have data, the event with the greatest message timestamp is returned.\n\n```go\nfunc (r *KafkaReader) Next(ctx context.Context) (*pb.Event, error)\n```\nNext blocks until the next event is available or ctx is cancelled.\n\n```go\ntype KafkaWriter struct {\n\t*kafka.Writer\n\t// contains filtered or unexported fields\n}\n```\nKafka writer is used to convert events from events.proto into kafka messages and to write them. it is built with 2 workers:\n\n\t#1 is gathering kafka.Message from any goroutine which sends message into buffered channel and puts them into FifoBuffer.\n\t#2 is poping any messages from FifoBuffer and sends them to Kafka\n\n\tThe reason for this setup over setting Async: true in kafka.Writer is the ability to have some error handling\n\tof failed messages. Moreover if we used only one worker that gathers messages from channel and then sends them directly to Kafka,\n\twe would block whole core if we receive lot of messages at once. So we split functionality into two workers: one is\n\tputting all messages into the buffer, so if we have a lot of messages buffer just grows without blocking whole core and the\n\tsecond does all the sending. This setup allows us to gather messages from any amount of goroutines without blocking/losing messages.\n\tAnother benefit is batching messages instead of writing them one by one.\n\n```go\nfunc NewWriterWithTopic(topic topic.Topic) *KafkaWriter\n```\n\n```go\nfunc (w *KafkaWriter) Close()\n```\n\n```go\nfunc (w *KafkaWriter) WriteEvent(e interface{})\n```\n\n```go\nfunc (w *KafkaWriter) WriteEventWithTimestamp(e interface{}, timestamp time.Time)\n```\n\n```go\ntype Reader interface {\n\t// Next should return the next event or cancel if the context is cancelled.\n\tNext(ctx context.Context) (*pb.Event, error)\n\t// Last should return the last available event currently present on the topic (or nil if none)\n\t// or cancel if the context is cancelled.\n\tLast(ctx context.Context) (*pb.Event, error)\n\tClose() error\n}\n```\nReader interface provides methods to read events.\n\n```go\ntype RoleEvent struct {\n\tName     string\n\tStatus   string\n\tState    string\n\tRolePath string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (e *RoleEvent) GetLabels() map[string]string\n```\n\n```go\nfunc (r *RoleEvent) GetName() string\n```\n\n```go\nfunc (r *RoleEvent) GetRolePath() string\n```\n\n```go\nfunc (r *RoleEvent) GetState() string\n```\n\n```go\nfunc (r *RoleEvent) GetStatus() string\n```\n\n```go\nfunc (e *RoleEvent) GetTimestamp() string\n```\n\n```go\nfunc (e *RoleEvent) SetLabels(labels map[string]string)\n```\n\n```go\ntype TaskEvent struct {\n\tName      string\n\tTaskID    string\n\tStatus    string\n\tState     string\n\tHostname  string\n\tClassName string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *TaskEvent) GetClassName() string\n```\n\n```go\nfunc (r *TaskEvent) GetHostname() string\n```\n\n```go\nfunc (e *TaskEvent) GetLabels() map[string]string\n```\n\n```go\nfunc (r *TaskEvent) GetName() string\n```\n\n```go\nfunc (r *TaskEvent) GetState() string\n```\n\n```go\nfunc (r *TaskEvent) GetStatus() string\n```\n\n```go\nfunc (r *TaskEvent) GetTaskID() string\n```\n\n```go\nfunc (e *TaskEvent) GetTimestamp() string\n```\n\n```go\nfunc (e *TaskEvent) SetLabels(labels map[string]string)\n```\n\n```go\ntype TaskInternalError struct {\n\tDeviceEventBase\n}\n```\n\n```go\nfunc (e *TaskInternalError) GetLabels() map[string]string\n```\n\n```go\nfunc (e *TaskInternalError) GetName() string\n```\n\n```go\nfunc (e *TaskInternalError) GetTimestamp() string\n```\n\n```go\nfunc (e *TaskInternalError) SetLabels(labels map[string]string)\n```\n\n```go\ntype TasksReleasedEvent struct {\n\tEnvironmentId     uid.ID           `json:\"environmentId\"`\n\tTaskIdsReleased   []string         `json:\"taskIdsReleased\"`\n\tTaskReleaseErrors map[string]error `json:\"taskReleaseErrors\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewTasksReleasedEvent(envId uid.ID, taskIdsReleased []string, taskReleaseErrors map[string]error) (tr *TasksReleasedEvent)\n```\n\n```go\nfunc (tr *TasksReleasedEvent) GetEnvironmentId() uid.ID\n```\n\n```go\nfunc (e *TasksReleasedEvent) GetLabels() map[string]string\n```\n\n```go\nfunc (tr *TasksReleasedEvent) GetName() string\n```\n\n```go\nfunc (tr *TasksReleasedEvent) GetTaskIds() []string\n```\n\n```go\nfunc (tr *TasksReleasedEvent) GetTaskReleaseErrors() map[string]error\n```\n\n```go\nfunc (e *TasksReleasedEvent) GetTimestamp() string\n```\n\n```go\nfunc (e *TasksReleasedEvent) SetLabels(labels map[string]string)\n```\n\n```go\ntype TasksStateChangedEvent struct {\n\tEnvironmentId       uid.ID   `json:\"environmentId\"`\n\tTaskIdsStateChanged []string `json:\"taskIdsStatesChanged\"`\n\tTaskStateChangedErr error    `json:\"taskStateChangedErr\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewTasksStateChangedEvent(envId uid.ID, taskIdsChangeState []string, taskStateChangedErr error) (tr *TasksStateChangedEvent)\n```\n\n```go\nfunc (tr *TasksStateChangedEvent) GetEnvironmentId() uid.ID\n```\n\n```go\nfunc (e *TasksStateChangedEvent) GetLabels() map[string]string\n```\n\n```go\nfunc (tr *TasksStateChangedEvent) GetName() string\n```\n\n```go\nfunc (tr *TasksStateChangedEvent) GetTaskIds() []string\n```\n\n```go\nfunc (tr *TasksStateChangedEvent) GetTasksStateChangedError() error\n```\n\n```go\nfunc (e *TasksStateChangedEvent) GetTimestamp() string\n```\n\n```go\nfunc (e *TasksStateChangedEvent) SetLabels(labels map[string]string)\n```\n\n```go\ntype Writer interface {\n\tWriteEvent(e interface{})\n\tWriteEventWithTimestamp(e interface{}, timestamp time.Time)\n\tClose()\n}\n```\n\n","path":"github.com/AliceO2Group/Control/common/event","name":"event","synopsis":"Package event provides event publishing and streaming functionality for O² Control components, supporting Kafka and dummy event writers.","isRedistributable":true}
