events

package module
v0.0.0-...-87aa12a Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

polypully-events

This module provides event handling capabilities for the PolyPully ecosystem.

Getting Started

To get started with polypully-events, clone the repository and build the project.

git clone https://github.com/matthogan/polypully-events.git
cd polypully-events
make

This run all tests.

Usage

To use polypully-events in your Go project, you need to import it:

import "github.com/matthogan/polypully-events"

Then, you can use the functions provided by polypully-events. Here's an example:

// create an event
event := polypully_events.NewEvent("MyEvent")
// ...

License

polypully-events is licensed under the Apache License 2.0.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dummy

type Dummy struct {
	Events
}

func (*Dummy) Close

func (e *Dummy) Close()

Close the producer

func (*Dummy) Notify

func (e *Dummy) Notify(event *Event) error

Notify sends an event

type Event

type Event struct {
	// any string that makes sense in the context of the client such as "Error"
	Type string
	// context such as an error message
	Value string
	// correlation id to group messages
	CorrelationId string
	// content type such as application/json
	ContentType string
}

func NewDownloadEvent

func NewDownloadEvent(value string, correlationId string) *Event

func NewServiceEvent

func NewServiceEvent(value string) *Event

type Events

type Events struct {
	Producer KafkaProducer
	// contains filtered or unexported fields
}

func (*Events) Close

func (e *Events) Close()

Close the producer

func (*Events) Notify

func (e *Events) Notify(event *Event) error

Notify sends an event

type EventsApi

type EventsApi interface {
	Notify(*Event) error
	Close()
	// contains filtered or unexported methods
}

func NewEvents

func NewEvents(config *EventsConfig) (EventsApi, error)

type EventsConfig

type EventsConfig struct {
	Enabled          bool              // disabled returns a dummy producer
	BootstrapServers string            // comma separated list of brokers
	ClientId         string            // identify the client in the logs
	Acks             string            // defaults to all
	Topic            string            // eg. "downloads"
	ProducerId       string            // identify the producer such as node name, etc
	Config           map[string]string // any other kafka producer config
}

type KafkaProducer

type KafkaProducer interface {
	Produce(msg *kafka.Message, deliveryChan chan kafka.Event) error
	Close()
	Events() chan kafka.Event
}

Jump to

Keyboard shortcuts

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