broker

package
v0.0.0-...-ed33083 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LEADER    = "leader"
	FOLLOWER  = "follower"
	CANDIDATE = "candidate"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	Name   string
	Peers  []Peer
	Topics []*topic.Topic

	Id          int
	Role        string
	CurrentTerm int
	VotedFor    int
	// contains filtered or unexported fields
}

func NewBroker

func NewBroker(opts BrokerOpts) (*Broker, error)

func (*Broker) AddPeerToList

func (b *Broker) AddPeerToList(peerDataArray []PeerData) error

Adds peer to list

func (*Broker) AppendEntriesLoop

func (b *Broker) AppendEntriesLoop(msg api.Message)

func (*Broker) AppendEntriesRPC

func (b *Broker) AppendEntriesRPC(args *api.AppendEntriesArgs, reply *api.AppendEntriesReply) error

func (*Broker) AppendTopicLoop

func (b *Broker) AppendTopicLoop()

func (*Broker) AppendTopicRPC

func (b *Broker) AppendTopicRPC(args *api.AppendTopicArgs, reply *api.AppendTopicReply) error

func (*Broker) CheckIfPeerAlreadyInList

func (b *Broker) CheckIfPeerAlreadyInList(peer []PeerData) bool

Checks if peer is already in maintained list

func (*Broker) ClearCluster

func (b *Broker) ClearCluster() error

Clears the cluster from etcd

func (*Broker) Consume

func (b *Broker) Consume(fetchReq api.FetchMessage) (api.Message, error)

Consunmer Manger functions

func (*Broker) CreateTopic

func (b *Broker) CreateTopic(name string, replicationFactor int, partitionCount int) error

CreateTopic creates a new topic

func (*Broker) GetPeerList

func (b *Broker) GetPeerList() ([]PeerData, error)

Equivalent of GetPeers function

func (*Broker) GetPeers

func (b *Broker) GetPeers() []Peer

func (*Broker) InitPeers

func (b *Broker) InitPeers()

func (*Broker) PeerRefreshLoop

func (b *Broker) PeerRefreshLoop()

Keeps checking if new peers have been added in the kv store

func (*Broker) PrintRPC

func (b *Broker) PrintRPC(args *int, reply *int) error

func (*Broker) Produce

func (b *Broker) Produce(msg api.Message) error

Producer Manager functions

func (*Broker) Start

func (b *Broker) Start()

func (*Broker) StartRPCServer

func (b *Broker) StartRPCServer(wg *sync.WaitGroup)

Starts the server for raft related RPC calls

func (*Broker) StartServer

func (b *Broker) StartServer()

type BrokerOpts

type BrokerOpts struct {
	Id        int    `json:"id"`
	Name      string `json:"name"`
	BrokerUri string `json:"broker_uri"`
	RpcUri    string `json:"rpc_uri"`
	Role      string `json:"role"`
}

type CreateTopicRequest

type CreateTopicRequest struct {
	Name              string `json:"name"`
	ReplicationFactor int    `json:"replicationFactor"`
	PartitionCount    int    `json:"partitionCount"`
}

type Peer

type Peer struct {
	Data PeerData
	// contains filtered or unexported fields
}

type PeerData

type PeerData struct {
	Id  int    `json:"id"`
	Uri string `json:"uri"`
}

Jump to

Keyboard shortcuts

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