Documentation ¶
Index ¶
- Variables
- type HTTPStream
- func (h *HTTPStream) Accept() (net.Conn, error)
- func (h *HTTPStream) Addr() net.Addr
- func (h *HTTPStream) Close() error
- func (h *HTTPStream) Dial(address raft.ServerAddress, timeout time.Duration) (net.Conn, error)
- func (h *HTTPStream) Network() string
- func (h *HTTPStream) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *HTTPStream) String() string
- type Node
- func (n *Node) AddPeer(name string) error
- func (n *Node) All(to interface{}, limit int, skip int, reverse bool) error
- func (n *Node) Bootstrap() error
- func (n *Node) Delete(data interface{}) error
- func (n *Node) Find(field string, value interface{}, to interface{}, limit int, skip int, ...) error
- func (n *Node) LastIndex() uint64
- func (n *Node) LeaderCh() <-chan bool
- func (n *Node) One(fieldName string, value interface{}, to interface{}) error
- func (n *Node) PostApply(_ bool, command database.Command, data interface{})
- func (n *Node) RegisterListener(listener database.Listener)
- func (n *Node) Router(router *gin.RouterGroup)
- func (n *Node) Run()
- func (n *Node) Save(data interface{}) error
- type RestAPI
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoLeader will be returned if an operation requires a leader - but // we have none. ErrNoLeader = errors.New("no leader") )
Functions ¶
This section is empty.
Types ¶
type HTTPStream ¶
type HTTPStream struct {
// contains filtered or unexported fields
}
HTTPStream implements a raft stream for use with Golang's net/http.
func NewHTTPStream ¶
func NewHTTPStream(addr string, certificates []tls.Certificate, coreCA *ca.CA) (*HTTPStream, error)
NewHTTPStream will instantiate a new HTTPStream.
func (*HTTPStream) Accept ¶
func (h *HTTPStream) Accept() (net.Conn, error)
Accept waits for and returns the next connection to the listener.
func (*HTTPStream) Addr ¶
func (h *HTTPStream) Addr() net.Addr
Addr returns the listener's network address.
func (*HTTPStream) Close ¶
func (h *HTTPStream) Close() error
Close closes the listener. Any blocked Accept operations will be unblocked and return errors.
func (*HTTPStream) Dial ¶
func (h *HTTPStream) Dial(address raft.ServerAddress, timeout time.Duration) (net.Conn, error)
Dial will dial a remote http endpoint (and implement raft.StreamLayer).
func (*HTTPStream) ServeHTTP ¶
func (h *HTTPStream) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a single gansoi node.
func NewNode ¶
func NewNode(stream raft.StreamLayer, datadir string, db database.Reader, fsm raft.FSM, self string, pair []tls.Certificate, coreCA *ca.CA) (*Node, func() error, error)
NewNode will initialize a new node.
func (*Node) Bootstrap ¶
Bootstrap will start a new Gansoi cluster. This should only be called for new clusters. Not new nodes in a existing cluster.
func (*Node) Find ¶
func (n *Node) Find(field string, value interface{}, to interface{}, limit int, skip int, reverse bool) error
Find find objects of type.
func (*Node) LastIndex ¶
LastIndex returns the last Raft index in stable storage, either from the last log or from the last snapshot.
func (*Node) LeaderCh ¶
LeaderCh is used to get a channel which delivers signals on acquiring or losing leadership. It sends true if we become the leader, and false if we lose it.
func (*Node) RegisterListener ¶
RegisterListener will register a listener for new changes to the database.
func (*Node) Router ¶
func (n *Node) Router(router *gin.RouterGroup)
Router can be used to assign a Gin routergroup.
type RestAPI ¶
type RestAPI[T any] struct { // contains filtered or unexported fields }
RestAPI is a generic way to build a REST-based API for the cluster database.
func NewRestAPI ¶
func NewRestAPI[T any](db database.ReadWriter) *RestAPI[T]
NewRestAPI will instantiate a new RestAPI.
func (*RestAPI[T]) Router ¶
func (r *RestAPI[T]) Router(router *gin.RouterGroup)
Router can be used to assign a Gin routergroup.