storeservice

package
v0.10.15 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package storeservice implements a storage service over Chirp.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Address is the address at which the service listens for connections.
	// This must be non-empty.
	Address string

	// Store is the storage exported by the service.
	// This must be non-nil.
	Store blob.StoreCloser

	// ReadOnly, if true, causes methods that modify the store to report errors
	// when called.
	ReadOnly bool

	// Prefix is prepended to the method names exportd by the service.
	// Any caller must use the same prefix.
	Prefix string

	// Logf, if set, is used to write text debug logs.
	// If nil, logs are discarded.
	Logf func(string, ...any)
}

Config carries the settings for a Service. The Address and Store fields are required.

type Service

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

Service manages a running server, accepting connections and delegating them to a peer implementing the chirpstore.Service methods.

func New

func New(config Config) *Service

New creates a new, unstarted service for the specified config. It will panic if any required config fields are missing. The caller must call Service.Start to start the service.

func (*Service) Address

func (s *Service) Address() string

Address returns the address for the service listener.

func (*Service) Root

func (s *Service) Root() *chirp.Peer

Root returns the root peer for the service. The caller may modify this peer, and such changes will affect future connections to the service but will not affect existing connections.

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start starts up the service loop for s. It will panic if s has already been started; otherwise it reports whether startup succeeded. Once started, s will run until ctx ends or Service.Stop is called. Start does not block while the service runs; call Service.Wait to wait for the service to shut down.

func (*Service) Stop

func (s *Service) Stop() error

Stop shuts down the service and waits for it to finish. If s is not started, Stop does nothing without error.

func (*Service) Wait

func (s *Service) Wait() error

Wait blocks until s has finished running.

Jump to

Keyboard shortcuts

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