server

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package server is used to start up the SIOT server, which includes NATS, the store, various built in clients, and HTTP API.

Index

Constants

This section is empty.

Variables

View Source
var ErrServerStopped = errors.New("Server stopped")

ErrServerStopped is returned when the server is stopped

View Source
var TestServerOptions = Options{
	StoreFile:    "test.sqlite",
	NatsPort:     8900,
	HTTPPort:     "8901",
	NatsHTTPPort: 8902,
	NatsWSPort:   8903,
	NatsServer:   "nats://localhost:8900",
	ID:           "inst1",
}

TestServerOptions options used for test server

View Source
var TestServerOptions2 = Options{
	StoreFile:    "test2.sqlite",
	NatsPort:     8910,
	HTTPPort:     "8911",
	NatsHTTPPort: 8912,
	NatsWSPort:   8913,
	NatsServer:   "nats://localhost:8910",
	ID:           "inst2",
}

TestServerOptions2 options used for 2nd test server

Functions

func TestServer added in v0.4.0

func TestServer(args ...string) (*nats.Conn, data.NodeEdge, func(), error)

TestServer starts a test server and returns a function to stop it

Types

type Options

type Options struct {
	StoreFile         string
	ResetStore        bool
	DataDir           string
	HTTPPort          string
	DebugHTTP         bool
	DebugLifecycle    bool
	NatsServer        string
	NatsDisableServer bool
	NatsPort          int
	NatsHTTPPort      int
	NatsWSPort        int
	NatsTLSCert       string
	NatsTLSKey        string
	NatsTLSTimeout    float64
	AuthToken         string
	ParticleAPIKey    string
	AppVersion        string
	OSVersionField    string
	LogNats           bool
	Dev               bool
	// optional ID (must be unique) for this instance, otherwise, a UUID will be used
	ID string
}

Options used for starting Simple IoT

func Args added in v0.5.2

func Args(args []string) (Options, error)

Args parses common SIOT command line options

type Server

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

Server represents a SIOT server process

func NewServer

func NewServer(o Options) (*Server, *nats.Conn, error)

NewServer creates a new server

func (*Server) AddClient added in v0.5.2

func (s *Server) AddClient(client client.RunStop)

AddClient can be used to add clients to the server. Clients must be added before start is called. The Server makes sure all clients are shut down before shutting down the server. This makes for a cleaner shutdown.

func (*Server) Run added in v0.7.1

func (s *Server) Run() error

Run the server -- only returns if there is an error

func (*Server) Stop

func (s *Server) Stop(_ error)

Stop server

func (*Server) WaitStart

func (s *Server) WaitStart(ctx context.Context) error

WaitStart waits for server to start. Clients should wait for this to complete before trying to fetch nodes, etc.

Jump to

Keyboard shortcuts

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