app

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 25 Imported by: 1

Documentation

Overview

package app provides a helper for building the common boilerplate for apps using this library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	// Name is the primary name of the application. It will be used to provide
	// default configuration for several elements, including logging and database
	// access.
	Name string

	// Version is the version of the app that is running. Typically this will come
	// from build-time generated code.
	Version string

	// InitDbMigration provides a hook for loading the proper db migration scripts
	// from the app. The shared code will handle running the migrations, but this
	// hook is responsible for any sorting that is needed as part of registering
	// them with the Migrator.
	InitDbMigration func(ctx context.Context, m *migrate.Migrator) error

	InitEnt func(ctx context.Context, drv *sql.Driver, logger func(args ...interface{}), debug bool) (ent.EntClientBase, error)

	// LoadOASSpec provides a hook for enabling OAS validation middleware, using
	// the returned swagger spec.
	LoadOASSpec func(ctx context.Context) (*openapi3.T, error)

	// OASFS specifies a "filesystem" to use for the `/oas` route, to serve
	// swagger specs to the swagger-ui (and thus this field enables the swagger-ui
	// routes too). This is typically an embed.FS wrapped in http.FS.
	OASFS http.FileSystem

	// SwaggerUIConfigHandler provides an optional override for handling the
	// `/oas-ui-config` route, for when extra OAS specs should be included, such
	// as when the gRPC HTTP gateway is in use. Note that the swagger ui (and thus
	// this) are only used if OASFS is non-nil.
	SwaggerUIConfigHandler http.HandlerFunc

	// Port is the default base listening port for the app to use. Debug/Test
	// configurations will commonly offset from this port. HTTP will typically run
	// on the base port (after any debug/test offsets), others will run offset
	// from this.
	Port int

	WithPubsubClient bool

	Grpc *AppGrpc

	Registry         *registry.Registry
	RegisterServices func(context.Context, *registry.Registry, registry.MutableValues) error
	CustomizeRoutes  func(context.Context, *gin.Engine, *registry.Registry, registry.MutableValues) error

	// App "ISA" DI root
	registry.MutableValues
	// contains filtered or unexported fields
}

func (*App) EntClient

func (app *App) EntClient() (ent.EntClientBase, bool)

func (*App) Main

func (app *App) Main() (err error)

func (*App) PubsubClient

func (app *App) PubsubClient() (pubsub.Client, bool)

func (*App) UseGinMiddleware added in v0.9.0

func (app *App) UseGinMiddleware(m func(*gin.Engine) error)

func (*App) WithDefaults

func (app *App) WithDefaults() *App

type AppGrpc

type AppGrpc struct {
	PortOffset     int
	ServerOpts     []grpc.ServerOption
	Initializer    grpccommon.GrpcInitializer
	GatewayPaths   []string
	OnGatewayStart func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error
}

Jump to

Keyboard shortcuts

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