eventline

package module
v0.0.0-...-c61d469 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

README

eventline

This simple package that presents one event in a line in a terminal

Documentation

Index

Constants

View Source
const (
	Aphabetical = iota
	Time
)
View Source
const (
	Desc = iota
	Asc
)

Variables

This section is empty.

Functions

func DebugSortMapByTime

func DebugSortMapByTime[T Event](data map[string]T, order int) ([]string, int)

DebugSortMapByTime sorts the provided map of events by timestamp in ascending or descending order, based on the order parameter. It returns a slice of formatted event presentations and the index of the last updated event, if applicable.

func LogInint

func LogInint(file *os.File) zerolog.Logger

LogInint initializes and returns a new zerolog.Logger with timestamping using the provided file for output.

Types

type Event

type Event interface {
	GetEventPresentation() string
	GetTimeStamp() time.Time
}

Event represents an interface for an event with methods for presentation and timestamp retrieval. GetEventPresentation provides a formatted string representation of the event. GetTimeStamp retrieves the timestamp associated with the event.

type EventLine

type EventLine[T Event] struct {
	// contains filtered or unexported fields
}

EventLine represents a processing pipeline for rendering events with various styles and configurations.

func NewPresenter

func NewPresenter[T Event](title string) *EventLine[T]

NewPresenter initializes and returns a new instance of EventLine with a title and configured tcell screen for display.

func (*EventLine[T]) AlphabeticalOrdered

func (p *EventLine[T]) AlphabeticalOrdered() *EventLine[T]

AlphabeticalOrdered sets the sorting style of the EventLine to alphabetical order and returns the updated instance.

func (*EventLine[T]) Close

func (p *EventLine[T]) Close()

Close releases resources associated with the screen and log file, ensuring proper cleanup and termination.

func (*EventLine[T]) Refresh

func (p *EventLine[T]) Refresh(alrmCount int, eventCount int, dataString []string, position int, userPosition int, lastUpdateIndex int)

Refresh clears the screen, updates the title, and renders event data at specified positions with highlighting.

func (*EventLine[T]) Send

func (p *EventLine[T]) Send(data Events[T])

Send publishes the given event data through the EventLine's internal channel for further processing and display.

func (*EventLine[T]) Start

func (p *EventLine[T]) Start(cancel func(), ctx context.Context)

Start initializes the EventLine's main loop, handling data processing, screen updates, and context cancellation.

func (*EventLine[T]) Stop

func (p *EventLine[T]) Stop()

Stop terminates the EventLine instance by performing cleanup operations and releasing associated resources.

func (*EventLine[T]) TimedOrdered

func (p *EventLine[T]) TimedOrdered(order int) *EventLine[T]

TimedOrdered configures the EventLine to sort events based on their timestamp and the specified order.

func (*EventLine[T]) WithLogFile

func (p *EventLine[T]) WithLogFile(fileName string) *EventLine[T]

WithLogFile associates a log file with the EventLine instance for logging operations and initializes the logger.

type Events

type Events[T Event] struct {
	GlobalEvents int
	LastUpdate   string
	EventsMap    map[string]T
}

Events represents a collection of event data supporting generics for flexible use with various event types. GlobalEvents tracks the total number of events. LastUpdate holds the identifier of the most recent update. EventsMap maps string keys to events of type T, providing efficient access to event data.

func DeepCopy

func DeepCopy[T Event](e Events[T]) Events[T]

DeepCopy creates a deep copy of the provided Events[T] instance, ensuring all contained data is duplicated.

func NewEventHandler

func NewEventHandler[T Event](ge int, em map[string]T, lastId string) Events[T]

NewEventHandler initializes and returns a new Events instance with the provided global event count, event map, and last update ID.

func (Events[T]) GetEventsListSize

func (e Events[T]) GetEventsListSize() int

GetEventsListSize returns the number of events currently stored in the EventsMap.

func (Events[T]) GetEventsMap

func (e Events[T]) GetEventsMap() map[string]T

GetEventsMap returns a shallow copy of the EventsMap, ensuring the original map remains unaffected by modifications.

func (Events[T]) GetGlobalEventsNumber

func (e Events[T]) GetGlobalEventsNumber() int

GetGlobalEventsNumber returns the total number of global events stored in the Events collection.

func (Events[T]) GetLastUpdateID

func (e Events[T]) GetLastUpdateID() string

GetLastUpdateID retrieves the identifier of the most recent update from the Events collection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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