httpd

package
v0.0.0-...-b510d8c Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package httpd provides the HTTP server for accessing the distributed key-value store. It also provides the endpoint for other nodes to join an existing cluster.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service provides HTTP service.

func New

func New(addr string, store Store) *Service

New returns an uninitialized HTTP service.

func (*Service) Addr

func (s *Service) Addr() net.Addr

Addr returns the address on which the Service is listening

func (*Service) Close

func (s *Service) Close()

Close closes the service.

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP allows Service to serve HTTP requests.

func (*Service) Start

func (s *Service) Start() error

Start starts the service.

type Store

type Store interface {
	// Get returns the value for the given key.
	Get(key string) (string, error)

	// Set sets the value for the given key, via distributed consensus.
	Set(key, value string) error

	// Delete removes the given key, via distributed consensus.
	Delete(key string) error

	// Join joins the node, identitifed by nodeID and reachable at addr, to the cluster.
	Join(nodeID string, addr string) error

	// GetInfo returns the information of raft store
	GetInfo() (*store.StoreInfo, error)
}

Store is the interface Raft-backed key-value stores must implement.

Jump to

Keyboard shortcuts

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