file

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilChan error = fmt.Errorf("Source channel is nil")

ErrNilChan indicates that the FilePublisher has no source channel

View Source
var ErrNoDest error = fmt.Errorf("No destination path set")

ErrNoDest indicates that the FilePublisher has no destination path

Functions

func NewPublisher

func NewPublisher(opts *Opts, src <-chan *sse.Event) (publisher.Publisher, error)

NewPublisher returns a Publisher initialized with the source channel and destination path provided

Types

type Opts

type Opts struct {
	Destination string
}

Opts hold config options for the file publisher

type Publisher

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

Publisher reads Events and writes them to disk

func (*Publisher) GetResumeID

func (f *Publisher) GetResumeID() string

GetResumeID attempts to read the ID of the last processed event from disk and returns it

func (*Publisher) ProcessEvent

func (f *Publisher) ProcessEvent(e *sse.Event) error

ProcessEvent writes a single event to a file

func (*Publisher) ReadAndPublish

func (f *Publisher) ReadAndPublish() (int64, error)

ReadAndPublish will read Events from the input channel and write them to file File names are sequential and relative to the destination directory If the FilePublisher's destionation directory is not set, ReadAndPublish returns ErrNoDest

Calling ReadAndPublish() will reset the processed message counter of the underlying Publisher and returns the value of the counter when the Publisher's source channel is closed

func (*Publisher) ValidateConnection

func (f *Publisher) ValidateConnection() error

ValidateConnection always returns nil and only serves to satisfy the Publisher interface

type PublisherConfig

type PublisherConfig struct {
	Destination string
}

PublisherConfig contains configuration for the file Publisher

Jump to

Keyboard shortcuts

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