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: 15 Imported by: 0

Documentation

Overview

Package service defines types for the chat service.

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")

	// ErrNotEvent is returned when the connected service is not an event emitter.
	ErrNotEvent = errors.New("connected service is not an event emitter")

	// ErrUnavailable is returned from gRPC methods when the service is not
	// available.
	ErrUnavailable = errors.New("the service is not available")
)

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."`

	// Event is the name of the event service.
	Event string `toml:"event" comment:"The name of the event service."`

	// HistoryDBPath is the path of the chat history db file.
	HistoryDBPath string `toml:"history_db_path" comment:"The path of the chat history db file."`
}

Config contains configuration options for the Chat service.

type Host

type Host = ihost.Host

Host represents a Stratumn Node host.

type Manager

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

Manager manages a chat history.

func NewManager

func NewManager(dbPath string) (*Manager, error)

NewManager creates a new chat manager.

func (*Manager) Add

func (m *Manager) Add(peerID peer.ID, message *pb.DatedMessage) error

Add adds a message to the history of a peer.

func (*Manager) Get

func (m *Manager) Get(peerID peer.ID) (PeerHistory, error)

Get returns the chat history with a peer.

type PeerHistory

type PeerHistory []pb.DatedMessage

PeerHistory represents a list of messages

type Service

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

Service is the Chat service.

func (*Service) AddToGRPCServer

func (s *Service) AddToGRPCServer(gs *grpc.Server)

AddToGRPCServer adds the service to a gRPC server.

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 chat service to other services. It is currently not exposed.

func (*Service) ID

func (s *Service) ID() string

ID returns the unique identifier of the service.

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(services 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 handler.

Jump to

Keyboard shortcuts

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