emulator

package
v0.0.0-...-864a747 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WebHookEndpointTransaction = "/hook/transaction"
	MessageEndpoint            = "/message"
)

Variables

View Source
var ErrFailedHook = errors.New("failed to create web hook")

Functions

func RunGenesis

func RunGenesis(ctx context.Context, cancel context.CancelFunc, config Config) error

func RunPublisher

func RunPublisher(ctx context.Context, cancel context.CancelFunc, config Config, data []byte) error

RunPublisher runs publisher emulator that emulates data in a buffer. Running emulator is stopped by canceling context.

func RunSubscriber

func RunSubscriber(ctx context.Context, cancel context.CancelFunc, config Config, data []byte) error

RunSubscriber runs subscriber emulator. To stop the subscriber cancel the context.

Types

type Config

type Config struct {
	ClientURL             string   `yaml:"client_url"`
	Port                  string   `yaml:"port"`
	PublicURL             string   `yaml:"public_url"`
	ReceiverPublicAddr    string   `yaml:"receiver_public_address"`
	NotaryNodes           []string `yaml:"notary_nodes"`
	TickMillisecond       int64    `yaml:"tick_millisecond"`
	Random                bool     `yaml:"random"`
	SpicePerTransaction   int      `yaml:"spice_per_transaction"`
	SleepInSecBeforeStart int      `yaml:"sleep_in_seconds_before_start"`
}

Config contains configuration for the emulator Publisher and Subscriber.

type Measurement

type Measurement struct {
	Volts int64 `json:"volts"`
	Mamps int64 `json:"m_amps"`
	Power int64 `json:"power"`
}

Measurement is data structure containing measurements received in a single transaction.

type Message

type Message struct {
	Status      string                  `json:"status"`
	Transaction transaction.Transaction `json:"transaction"`
	Timestamp   int64                   `json:"timestamp"`
	Volts       int64                   `json:"volts"`
	MiliAmps    int64                   `json:"mili_amps"`
	Power       int64                   `json:"power"`
}

Message holds timestamp info.

Jump to

Keyboard shortcuts

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