service

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimpleApp added in v0.0.2

func SimpleApp(migrations []string, transactions map[string]store.TxHandler, handler AppHandlerFunc) *simpleApp

SimpleApp returns a minimum viable App for use with Serve()

Types

type App

type App interface {
	Migrations() []string
	Transactions() map[string]store.TxHandler
	Public(store *store.Store) http.Handler
	Private(store *store.Store) http.Handler
	Log() *slog.Logger
}

App provides an application's logic to a service.

type AppHandlerFunc added in v0.0.2

type AppHandlerFunc func(store *store.Store) http.Handler

type Service

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

Service is a libsdk service which contains public and private servers, a fabric, and a store for simple service development.

func New

func New(name string) (*Service, error)

New creates a Service with a SQLite store and NATS fabric.

func NewWithFabricStore

func NewWithFabricStore(name string, fabric fabric.Fabric, store *store.Store) (*Service, error)

NewWithFabricStore creates a Service with the provided fabric and store.

func (*Service) Serve

func (s *Service) Serve(app App) error

Serve takes in an App definition and begins serving the public and private handlers. - App's public handler is served on an HTTP port defined by LIBSDK_PUBLIC_PORT, defaulting to :8080 - App's private handler is served using the configured fabric. - App's transaction handlers are registered for use by the store. - App's migrations are applied to the store before replaying transactions.

func (*Service) Store

func (s *Service) Store() *store.Store

Store returns the Service's store, which should be used by handlers to read and write from the replicated database via store.Exec.

Jump to

Keyboard shortcuts

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