transport

package module
v0.0.0-...-c64e6b3 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 10 Imported by: 0

README

raft-grpc-transport-mux

Godoc

This library provides a Transport for https://github.com/hashicorp/raft over gRPC.

One benefit of this is that gRPC is easy to multiplex over a single port. It is an extension of original https://github.com/Jille/raft-grpc-transport and an example how to multiplex more Raft groups in the single process.

Usage

// ...
tm := transport.New(raft.ServerAddress(myAddress), []grpc.DialOption{grpc.WithInsecure()})
s := grpc.NewServer()
tm.Register(s)
r, err := raft.NewRaft(..., tm.Transport("group1"))
// ...
r2, err := raft.NewRaft(..., tm.Transport("group2"))
// ...

Want more example code? Check out main.go at https://github.com/Jille/raft-grpc-example

Documentation

Overview

Package transport provides Transport for github.com/hashicorp/raft over gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func New

func New(localAddress raft.ServerAddress, dialOptions []grpc.DialOption, options ...Option) *Manager

New creates both components of raft-grpc-transport: a gRPC service and a Raft Transport.

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) Register

func (m *Manager) Register(s *grpc.Server)

Register the RaftTransport gRPC service on a gRPC server.

func (*Manager) Transport

func (m *Manager) Transport(group string) raft.Transport

Transport returns a raft.Transport that communicates over gRPC. Group string scopes the communication under this string label. That allows for reusing Transport manager (and its connections) by multiple `raft.Raft` instances.

type Option

type Option func(m *Manager)

func WithHeartbeatTimeout

func WithHeartbeatTimeout(d time.Duration) Option

WithHeartbeatTimeout configures the transport to not wait for than d for heartbeat to be executes by remote peer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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