hops

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package hops contains the logic for running the hops server components and handling workloads

Index

Constants

View Source
const AutomationsHashKey = "hops"

Variables

This section is empty.

Functions

func ConsoleRouter added in v0.13.0

func ConsoleRouter(logger zerolog.Logger) chi.Router

The console router serves the single page app for the console. It will serve the index.html file for any path that does not exist, allowing client-side to handle routing

func EventRouter added in v0.13.0

func EventRouter(eventsClient EventsClient, logger zerolog.Logger) chi.Router

func Healthcheck added in v0.13.0

func Healthcheck(natsClient *nats.Client, endpoint string) func(http.Handler) http.Handler

Types

type AutomationsLoader added in v0.17.0

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

func NewAutomationsLoader added in v0.17.0

func NewAutomationsLoader(path string, tolerant bool, natsClient *nats.Client, logger zerolog.Logger) (*AutomationsLoader, error)

func (*AutomationsLoader) Get added in v0.17.0

func (al *AutomationsLoader) Get(hash string) (*dsl.Automations, error)

Get returns the automations for the given hash key or the local automations if hash key is the empty string

func (*AutomationsLoader) GetForSequence added in v0.17.0

func (al *AutomationsLoader) GetForSequence(ctx context.Context, sequenceID string, msgBundle nats.MessageBundle) (*dsl.Automations, error)

GetForSequence returns the Automations assigned to an event sequence. If no Automations are assigned to a sequence, it first assigns and then returns the local Automations

This ensures that sequences are handled by a consistent configuration until completion, even if multiple hops instances handle the work.

func (*AutomationsLoader) GetFromCache added in v0.17.0

func (al *AutomationsLoader) GetFromCache(hash string) *dsl.Automations

GetFromCache returns Automations by hash key from the local cache

func (*AutomationsLoader) GetFromStore added in v0.17.0

func (al *AutomationsLoader) GetFromStore(hash string) (*dsl.Automations, error)

GetFromStore returns the Automations by hash key from object storage

func (*AutomationsLoader) GetOrSetHashForSequence added in v0.17.0

func (al *AutomationsLoader) GetOrSetHashForSequence(ctx context.Context, sequenceID string, msgBundle nats.MessageBundle) (string, error)

GetOrSetHashForSequence returns the Automations hash assigned to an event sequence. If no hash are assigned to a sequence, it first assigns and then returns the local Automations

This ensures that sequences are handled by a consistent configuration until completion, even if multiple hops instances handle the work.

func (*AutomationsLoader) Reload added in v0.17.0

func (al *AutomationsLoader) Reload(ctx context.Context, tolerant bool) error

func (*AutomationsLoader) Save added in v0.17.0

func (al *AutomationsLoader) Save() error

func (*AutomationsLoader) SaveInCache added in v0.17.0

func (al *AutomationsLoader) SaveInCache(a *dsl.Automations, ttl time.Duration)

func (*AutomationsLoader) SaveInStore added in v0.17.0

func (al *AutomationsLoader) SaveInStore(a *dsl.Automations) error

type DirNotifier added in v0.13.0

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

DirNotifier watches a path and its subdirectories for changes notifying when one occurs

func NewDirNotifier added in v0.13.0

func NewDirNotifier(path string) (*DirNotifier, error)

func (*DirNotifier) Close added in v0.13.0

func (d *DirNotifier) Close() error

func (*DirNotifier) Notifier added in v0.13.0

func (d *DirNotifier) Notifier(ctx context.Context) reload.Notifier

type ErrFailedHopsParse added in v0.14.1

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

func (ErrFailedHopsParse) Error added in v0.14.1

func (e ErrFailedHopsParse) Error() string

type Event added in v0.13.0

type Event interface{}

Event is arbitrary json struct of event

type EventItem added in v0.13.0

type EventItem struct {
	Event       Event     `json:"event"`
	SequenceId  string    `json:"sequence_id"`
	Timestamp   time.Time `json:"timestamp"`
	AppName     string    `json:"app_name"`
	Channel     string    `json:"channel"`
	Done        bool      `json:"done"`
	HandlerName string    `json:"handler_name"`
	MessageId   string    `json:"message_id"`
}

EventItem includes metadata for /events api endpoint

type EventLog added in v0.13.0

type EventLog struct {
	StartTimestamp time.Time   `json:"start_timestamp"`
	EndTimestamp   time.Time   `json:"end_timestamp"`
	EventItems     []EventItem `json:"event_items"`
}

EventLog is a list of events with search start and search end timestamps

type EventsClient added in v0.13.0

type EventsClient interface {
	GetEventHistory(ctx context.Context, start time.Time, sourceOnly bool) ([]*nats.MsgMeta, error)
}

type HTTPAppConf added in v0.13.0

type HTTPAppConf struct {
	Serve bool
}

type HTTPServer added in v0.13.0

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

func NewHTTPServer added in v0.13.0

func NewHTTPServer(addr string, automationsLoader *AutomationsLoader, natsClient *nats.Client, logger zerolog.Logger) (*HTTPServer, error)

func (*HTTPServer) Reload added in v0.13.0

func (h *HTTPServer) Reload(ctx context.Context) error

func (*HTTPServer) Serve added in v0.13.0

func (h *HTTPServer) Serve() error

func (*HTTPServer) Shutdown added in v0.13.0

func (h *HTTPServer) Shutdown(ctx context.Context) error

type HTTPServerConf added in v0.13.0

type HTTPServerConf struct {
	Address string
	Serve   bool
}

type HopsServer

type HopsServer struct {
	HopsPath    string
	KeyFilePath string
	Logger      zerolog.Logger
	ReplayEvent string
	Watch       bool

	HTTPServerConf
	HTTPAppConf
	K8sAppConf
	RunnerConf
	// contains filtered or unexported fields
}

func (*HopsServer) Start

func (h *HopsServer) Start(ctx context.Context) error

type K8sAppConf added in v0.13.0

type K8sAppConf struct {
	KubeConfig  string
	PortForward bool
	Serve       bool
}

type Runner

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

func NewRunner added in v0.13.0

func NewRunner(natsClient *nats.Client, automationsLoader *AutomationsLoader, logger zerolog.Logger) (*Runner, error)

func (*Runner) Reload added in v0.13.0

func (r *Runner) Reload(ctx context.Context) error

func (*Runner) Run added in v0.13.0

func (r *Runner) Run(ctx context.Context, fromConsumer string) error

func (*Runner) SequenceCallback added in v0.13.0

func (r *Runner) SequenceCallback(
	ctx context.Context,
	sequenceId string,
	msgBundle nats.MessageBundle,
) (bool, error)

type RunnerConf added in v0.13.0

type RunnerConf struct {
	Serve bool
	Local bool
}

type Schedule added in v0.13.0

type Schedule struct {
	Config       *dsl.ScheduleAST
	CronSchedule cron.Schedule
	// contains filtered or unexported fields
}

func NewSchedule added in v0.13.0

func NewSchedule(config *dsl.ScheduleAST, natsClient *nats.Client, logger zerolog.Logger) (*Schedule, error)

func (*Schedule) Run added in v0.13.0

func (s *Schedule) Run()

Jump to

Keyboard shortcuts

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