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

Documentation

Overview

Package service defines types for the contacts service.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a contact is not found.
	ErrNotFound = errors.New("contact not found")
)
View Source
var (
	// 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 {
	// Filename is the filename of the contacts file.
	Filename string `toml:"filename" comment:"The filename of the contacts file."`
}

Config contains configuration options for the Contacts service.

type Contact

type Contact struct {
	PeerID peer.ID
}

Contact represents a contact.

type Manager

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

Manager manages a contact list.

func NewManager

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

NewManager creates a new contact manager.

func (*Manager) Delete

func (m *Manager) Delete(name string) error

Delete deletes a contact by name.

func (*Manager) Get

func (m *Manager) Get(name string) (*Contact, error)

Get finds a contact by name.

It returns a copy of the value.

func (*Manager) List

func (m *Manager) List() map[string]Contact

List returns the list of contacts.

func (*Manager) Set

func (m *Manager) Set(name string, contact *Contact) error

Set sets or adds a contact.

A name is required because the name of the contact could change.

type Service

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

Service is the Contacts 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 service to other services.

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

Jump to

Keyboard shortcuts

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