service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package service defines a service that runs an instance of a Kademlia distributed hash table server or client that can be used to route peer IDs to network addresses.

It may also store other key values in addition to node IDs.

For more information on Kademlia DHT, checkout:

https://en.wikipedia.org/wiki/Kademlia

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotHost is returned when the connected service is not a host.
	ErrNotHost = errors.New("connected service is not a host")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Host is the name of the host service.
	Host string `toml:"host" comment:"The name of the host service."`

	// Bootstrap is the name of the bootstrap service.
	Bootstrap string `toml:"bootstrap" comment:"The name of the bootstrap service."`

	// LevelDBPath is the path to the LevelDB database directory.
	LevelDBPath string `toml:"level_db_path" comment:"The path to the LevelDB database directory."`

	// BootstrapQueries is the number of queries during a bootstrap job.
	BootstrapQueries int `toml:"bootstrap_queries" comment:"The number of queries during a bootstrap job."`

	// BootstrapInterval is how long to wait between bootstrap jobs.
	BootstrapInterval string `toml:"bootstrap_interval" comment:"How long to wait between bootstrap jobs."`

	// BootstrapTimeout is the timeout for a bootstrap job.
	BootstrapTimeout string `toml:"bootstrap_timeout" comment:"The timeout for a bootstrap job."`

	// EnableClientMode is whether to run only as a client and not to store
	// DHT values.
	EnableClientMode bool `toml:"enable_client_mode" comment:"Whether to run only as a client and not store DHT values."`
}

Config contains configuration options for the Kademlia DHT service.

type Host

type Host interface {
	ihost.Host

	SetRouter(func(context.Context, peer.ID) (pstore.PeerInfo, error))
}

Host represents a Stratumn Node host.

type Service

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

Service is the Kademlia DHT service.

func (*Service) Befriend

func (s *Service) Befriend(serviceID string, exposed interface{})

Befriend sets the liked services.

func (*Service) Config

func (s *Service) Config() interface{}

Config returns the current service configuration or creates one with good default values.

func (*Service) Desc

func (s *Service) Desc() string

Desc returns a description of what the service does.

func (*Service) Expose

func (s *Service) Expose() interface{}

Expose exposes the Kademlia DHT to other services.

It exposes the type:

github.com/libp2p/*go-libp2p-kad-dht.IpfsDHT

func (*Service) ID

func (s *Service) ID() string

ID returns the unique identifier of the service.

func (*Service) Likes

func (s *Service) Likes() map[string]struct{}

Likes returns the set of services this service can work with.

func (*Service) Name

func (s *Service) Name() string

Name returns the human friendly name of the service.

func (*Service) Needs

func (s *Service) Needs() map[string]struct{}

Needs returns the set of services this service depends on.

func (*Service) Plug

func (s *Service) Plug(exposed map[string]interface{}) error

Plug sets the connected services.

func (*Service) Run

func (s *Service) Run(ctx context.Context, running, stopping func()) error

Run starts the service.

func (*Service) SetConfig

func (s *Service) SetConfig(config interface{}) error

SetConfig configures the service.

Directories

Path Synopsis
Package mockservice is a generated GoMock package.
Package mockservice is a generated GoMock package.

Jump to

Keyboard shortcuts

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