gfsweb

package
v0.0.0-...-bcf6333 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigKeyDatabaseURL = "databases.app.url"

	SQLDatasourceName = "postgres"
)
View Source
const (
	ConfigKeyServerPort = "server.port"
)

Variables

This section is empty.

Functions

func CreateAPI

func CreateAPI(bus *cbus.Bus, repos *Repos) *api.API

CreateAPI returns a new api.API populated with bus and the query repositories in repos.

func CreateCBus

func CreateCBus(repos *Repos) *cbus.Bus

CreateCBus returns a new cbus.Bus with user and client commands registered on it.

func CreateSQLRepo

func CreateSQLRepo(config *config.Config) (*sqlrepo.Repo, io.Closer, error)

CreateSQLRepo returns a new sqlrepo.Repo and an io.Closer that will close the connection to the database.

It connects to a Postgresql database at the url specified in config at key ConfigKeyDatabaseURL.

func CreateServer

func CreateServer(c *config.Config) *server.Server

CreateServer returns a new Server that listens on the port specified in c at key ConfigKeyServerPort.

func RegisterClientCommands

func RegisterClientCommands(bus *cbus.Bus, clients client.Repo)

func RegisterUserCommands

func RegisterUserCommands(bus *cbus.Bus, users user.Repo)

Types

type APIFactory

type APIFactory func(bus *cbus.Bus, repos *Repos) *api.API

APIFactory is a function type that creates a new API ready for use.

type App

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

App is the central application type for the gfsweb executable.

func (*App) Close

func (a *App) Close() error

Close closes all internal resources held be a. This must be called regardless of the result from a.Run and should be called after Run returns.

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run runs a within ctx. It calls Serce on a's internal server.Server. It also waits in a sepearate goroutine for ctx to be done and calls Shutdown on the internal server.

type AppBuilder

type AppBuilder struct {
	SQLRepoFactory

	CBusFactory

	APIFactory

	ServerFactory
}

AppBuilder is a type that knows how to initialize and build everything required for an App.

func NewAppBuilder

func NewAppBuilder() *AppBuilder

NewAppBuilder returns a new AppBuilder with fields set to default values.

func (*AppBuilder) Build

func (ab *AppBuilder) Build(config *config.Config) (app *App, err error)

Build uses config and its factory functions to build a new App. If err is nil, the returned App is ready to Run.

type CBusFactory

type CBusFactory func(repos *Repos) *cbus.Bus

CBusFactory is a function type that creates a new cbus.Bus will all required Commands and Handlers correctly registered.

type Repos

type Repos struct {
	Users   user.Repo
	Clients client.Repo
}

Repos is a collection of domain type repositories used throughout the application. Passing this collection around is easier than passing all of them individually.

func NewRepos

func NewRepos(sqlRepo *sqlrepo.Repo) *Repos

NewRepos returns a new Repos with each repository created from each domain package's sql repo implementation.

type SQLRepoFactory

type SQLRepoFactory func(config *config.Config) (*sqlrepo.Repo, io.Closer, error)

SQLRepoFactory is a function type that creates a new sqlrepo.Reop and a related io.Closer that should close the connection to the database.

type ServerFactory

type ServerFactory func(config *config.Config) *server.Server

ServerFactory is a function type that creates a new server.Server ready for use.

Directories

Path Synopsis
handler
api

Jump to

Keyboard shortcuts

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