event

package
v0.0.0-...-45e1a9a Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LastEventNotFoundError error = errors.New("last event not found")
View Source
var MasterServerEvents = map[MasterServerEventType]string{
	MASTER_ALIVE: "MASTER_ALIVE",
	ASSIGN:       "ASSIGN",
}
View Source
var VolumeServerEvents = map[VolumeServerEventType]string{
	ALIVE:  "ALIVE",
	WRITE:  "WRITE",
	DELETE: "DELETE",
	VACUUM: "VACUUM",
}

Functions

This section is empty.

Types

type Event

type Event interface {
	SetType(t string)
	GetType() string

	GetServer() *event_pb.Server
	GetProofOfHistory() *event_pb.ProofOfHistory
	SetProofOfHistory(previousHash *string, hash string)

	GetKey() ([]byte, error)
	GetValue() ([]byte, error)
	// contains filtered or unexported methods
}

type EventStore

type EventStore[T Event] interface {
	RegisterEvent(T) error
	GetLastEvent() (T, error)
	ListAllEvents() ([]T, error)

	Close()
}

type KafkaStore

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

func NewKafkaStore

func NewKafkaStore(brokers []string, config *sarama.Config, producer sarama.SyncProducer) *KafkaStore

func (*KafkaStore) Close

func (ks *KafkaStore) Close()

func (*KafkaStore) Publish

func (ks *KafkaStore) Publish(topic string, key []byte, data []byte) (int32, int64, error)

type KafkaStoreTopics

type KafkaStoreTopics struct {
	Master string `toml:"kafka.topic.master"`
	Volume string `toml:"kafka.topic.volume"`
}

type LevelDbEventStore

type LevelDbEventStore[T Event] struct {
	EventStore[T]

	Dir string
	// contains filtered or unexported fields
}

func NewLevelDbEventStore

func NewLevelDbEventStore[T Event](
	eventDir string,
	kafkaBrokers *[]string,
	kafkaTopic *string,
	config *sarama.Config,
) (*LevelDbEventStore[T], error)

func (*LevelDbEventStore[T]) Close

func (es *LevelDbEventStore[T]) Close()

func (*LevelDbEventStore[T]) GetLastEvent

func (es *LevelDbEventStore[T]) GetLastEvent() (*T, error)

func (*LevelDbEventStore[T]) ListAllEvents

func (es *LevelDbEventStore[T]) ListAllEvents() ([]T, error)

func (*LevelDbEventStore[T]) RegisterEvent

func (es *LevelDbEventStore[T]) RegisterEvent(e T) error

type MasterServerEvent

type MasterServerEvent struct {
	// TODO: consider replacing with protobuf value
	Type      string                 `json:"type"`
	Timestamp *timestamppb.Timestamp `json:"timestamp"`

	Fid            string                   `json:"fid"`
	Locations      []*master_pb.Location    `json:"locations"`
	Server         *event_pb.Server         `json:"server"`
	ProofOfHistory *event_pb.ProofOfHistory `json:"proofOfHistory"`
}

func NewMasterServerEvent

func NewMasterServerEvent(
	eventType MasterServerEventType,
	fid *string,
	locations []*master_pb.Location,
	serverPublicUrl string,
) *MasterServerEvent

func (*MasterServerEvent) GetKey

func (mse *MasterServerEvent) GetKey() ([]byte, error)

func (*MasterServerEvent) GetProofOfHistory

func (mse *MasterServerEvent) GetProofOfHistory() *event_pb.ProofOfHistory

func (*MasterServerEvent) GetServer

func (mse *MasterServerEvent) GetServer() *event_pb.Server

func (*MasterServerEvent) GetType

func (mse *MasterServerEvent) GetType() string

func (*MasterServerEvent) GetValue

func (mse *MasterServerEvent) GetValue() ([]byte, error)

func (*MasterServerEvent) SetProofOfHistory

func (mse *MasterServerEvent) SetProofOfHistory(previousHash *string, hash string)

func (*MasterServerEvent) SetType

func (mse *MasterServerEvent) SetType(t string)

type MasterServerEventKey

type MasterServerEventKey struct {
	Server string `json:"server"`
	Type   string `json:"type"`
}

type MasterServerEventType

type MasterServerEventType uint32
const (
	MASTER_ALIVE MasterServerEventType = iota
	ASSIGN
)

type VolumeServerEvent

type VolumeServerEvent struct {
	*volume_server_pb.VolumeServerEventResponse
}

func (*VolumeServerEvent) GetKey

func (vse *VolumeServerEvent) GetKey() ([]byte, error)

func (*VolumeServerEvent) GetProofOfHistory

func (vse *VolumeServerEvent) GetProofOfHistory() *event_pb.ProofOfHistory

func (*VolumeServerEvent) GetServer

func (vse *VolumeServerEvent) GetServer() *event_pb.Server

func (*VolumeServerEvent) GetType

func (vse *VolumeServerEvent) GetType() string

func (*VolumeServerEvent) GetValue

func (vse *VolumeServerEvent) GetValue() ([]byte, error)

func (*VolumeServerEvent) SetProofOfHistory

func (vse *VolumeServerEvent) SetProofOfHistory(previousHash *string, hash string)

func (*VolumeServerEvent) SetType

func (vse *VolumeServerEvent) SetType(t string)

type VolumeServerEventKafkaKey

type VolumeServerEventKafkaKey struct {
	Type   string `json:"type"`
	Volume string `json:"volume"`
	Server string `json:"server"`
}

type VolumeServerEventType

type VolumeServerEventType uint32
const (
	ALIVE VolumeServerEventType = iota
	WRITE
	DELETE
	VACUUM
)

Jump to

Keyboard shortcuts

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