client

package
v0.0.0-...-92d349b Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StreamTypeSequencer represents a Sequencer stream
	StSequencer StreamType = 1

	// Packet types
	PtPadding = 0
	PtHeader  = 1    // Just for the header page
	PtData    = 2    // Data entry
	PtResult  = 0xff // Not stored/present in file (just for client command result)

)

Variables

View Source
var (
	ErrBadBookmark = errors.New("bad bookmark")
)

Functions

This section is empty.

Types

type Command

type Command uint64
const (
	// Commands
	CmdUnknown       Command = 0
	CmdStart         Command = 1
	CmdStop          Command = 2
	CmdHeader        Command = 3
	CmdStartBookmark Command = 4 // CmdStartBookmark for the start from bookmark TCP client command
	CmdEntry         Command = 5 // CmdEntry for the get entry TCP client command
	CmdBookmark      Command = 6 // CmdBookmark for the get bookmark TCP client command

	BookmarkLength = 9
)

type EntityDefinition

type EntityDefinition struct {
	Name       string
	StreamType StreamType
	Definition reflect.Type
}

type StreamClient

type StreamClient struct {
	Header types.HeaderEntry // Header info received (from Header command)

	// atomic
	LastWrittenTime atomic.Int64
	Streaming       atomic.Bool

	// Channels
	L2BlockChan    chan types.FullL2Block
	GerUpdatesChan chan types.GerUpdate
	// contains filtered or unexported fields
}

func NewClient

func NewClient(server string) StreamClient

Creates a new client fo datastream server must be in format "url:port"

func (*StreamClient) GetHeader

func (c *StreamClient) GetHeader() error

Command header: Get status Returns the current status of the header. If started, terminate the connection.

func (*StreamClient) ReadAllEntriesToChannel

func (c *StreamClient) ReadAllEntriesToChannel(bookmark *types.Bookmark) error

reads entries to the end of the stream at end will wait for new entries to arrive

func (*StreamClient) ReadEntries

func (c *StreamClient) ReadEntries(bookmark *types.Bookmark, l2BlocksAmount int) (*[]types.FullL2Block, *[]types.GerUpdate, map[uint64][]byte, uint64, error)

sends start command, reads entries until limit reached and sends end command

func (*StreamClient) Start

func (c *StreamClient) Start() error

Opens a TCP connection to the server

func (*StreamClient) Stop

func (c *StreamClient) Stop()

type StreamType

type StreamType uint64

Jump to

Keyboard shortcuts

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