types

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// MessageType return the message type which the handler want to collect
	MessageType() MessageType
	// GetRequiredMessageCount gets required message count in this round
	GetRequiredMessageCount() uint32
	// IsHandled checks if the id's message is handled before
	IsHandled(logger log.Logger, id string) bool
	// HandleMessage handles the message
	HandleMessage(logger log.Logger, msg Message) error
	// Finalize finalizes the result based on the collected messages and return the next handler.
	// If next handler is nil, it means it's the end of the main process
	Finalize(logger log.Logger) (Handler, error)
}

Handler defines the message handler

type MainState

type MainState uint32

MainState defines the msg main state

const (
	// StateInit is the state if the process is just created.
	StateInit MainState = 0
	// StateDone is the state if the process is done.
	StateDone MainState = 10
	// StateFailed is the state if the process is failed
	StateFailed MainState = 20
)

func (MainState) String

func (m MainState) String() string

type Message

type Message interface {
	// GetId returns the message id
	GetId() string
	// GetMessageType returns the message type
	GetMessageType() MessageType
	// IsValid checks if message is valid or not
	IsValid() bool
}

Message defines the message interface

type MessageMain

type MessageMain interface {
	AddMessage(senderId string, msg Message) error
	GetHandler() Handler
	GetState() MainState
	Start()
	Stop()
}

MessageMain defines the message main interface

type MessageType

type MessageType int32

MessageType defines the message state

type PeerManager

type PeerManager interface {
	NumPeers() uint32
	PeerIDs() []string
	SelfID() string
	MustSend(id string, msg interface{})
}

PeerManager defines the peer interface

type StateChangedListener

type StateChangedListener interface {
	OnStateChanged(oldState MainState, newState MainState)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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