Documentation ¶
Overview ¶
Package tron contains base application object, some options and functions to create base app.
Index ¶
- func SetName(name string)
- type App
- func (a *App) Close()
- func (a *App) Health() healthcheck.Checker
- func (a *App) Info() *Info
- func (a *App) Logger() *zap.Logger
- func (a *App) Router() chi.Router
- func (a *App) Run(impl ...transport.Service) error
- func (a *App) TraceLogger() tracelog.Logger
- func (a *App) Tracer() *tracing.Tracer
- func (a *App) WithRunOptions(opts ...app.RunOption) *App
- type Info
- type Option
- func AddLogCaller() Option
- func AddLogStacktrace(level string) Option
- func WithAdminHTTP(port uint16) Option
- func WithCORSAllowedAuthentication(allow bool) Option
- func WithCORSAllowedHeaders(headers []string) Option
- func WithCORSAllowedOrigins(origins []string) Option
- func WithConfigMap(cfg map[string]interface{}) Option
- func WithExitSignals(sig ...os.Signal) Option
- func WithGRPCListener(listener net.Listener) Option
- func WithHTTPListener(listener net.Listener) Option
- func WithLogField(key string, value interface{}) Option
- func WithPublicGRPC(port uint16) Option
- func WithPublicHTTP(port uint16) Option
- func WithRealtimeConfig() Option
- type RunOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is base application object with grpc and http servers, logger and tracer.
func (*App) Health ¶ added in v0.14.0
func (a *App) Health() healthcheck.Checker
Health returns application health checker.
func (*App) TraceLogger ¶
TraceLogger returns wrapped zap logger with opentracing metadata injection to log records.
type Option ¶
Option sets tron options such as ports, config, etc.
func AddLogCaller ¶
func AddLogCaller() Option
AddLogCaller configures the Logger to annotate each message with the filename and line number of zap's caller.
func AddLogStacktrace ¶
AddLogStacktrace configures the Logger to record a stack trace for all messages at or above a given level.
Example: tron.New(tron.AddLogStacktrace("error"))
func WithAdminHTTP ¶
WithAdminHTTP returns a Option that sets admin http port. Cannot be changed by config or env.
Example: tron.New(tron.WithAdminHTTP(8081))
func WithCORSAllowedAuthentication ¶ added in v0.2.1
WithCORSAllowedAuthentication sets if HTTP client allows authentication like cookies, SSL certs and HTTP basic auth.
func WithCORSAllowedHeaders ¶ added in v0.2.1
WithCORSAllowedHeaders sets a list of non simple headers the HTTP client is allowed to use with cross-domain requests. If the special "*" value is present in the list, all headers will be allowed. Default value is [] but "Origin" is always appended to the list.
func WithCORSAllowedOrigins ¶ added in v0.2.1
WithCORSAllowedOrigins sets allowed origin domains for cross-domain requests. If the special "*" value is present in the list, all origins will be allowed. An origin may contain a wildcard (*) to replace 0 or more characters (i.e.: http://*.domain.com). Usage of wildcards implies a small performance penality. Only one wildcard can be used per origin. Default option enable CORS for requests on admin port.
func WithConfigMap ¶ added in v0.7.0
WithConfigMap returns a Option that init app config from map and envs.
Example: tron.New(tron.WithConfigMap(map[string]interface{}{ "namespace": "dev", "service_port_grpc": 35900, "cockroach_addr": "db_addr", "cockroach_user": "db_user", "cockroach_db": "db_name", }))
func WithExitSignals ¶
WithExitSignals returns a Option that sets exit signals for application. Default signals is: syscall.SIGTERM, syscall.SIGINT.
Example: tron.New(tron.WithExitSignals(syscall.SIGKILL))
func WithGRPCListener ¶ added in v0.7.0
WithGRPCListener returns a Option that sets net listener for grpc public server. Can be used for create application tests with memory listener.
Example: listener := bufconn.Listen(1024*1024) tron.New(tron.WithGRPCListener(listener))
func WithHTTPListener ¶ added in v0.7.0
WithHTTPListener returns a Option that sets net listener for http public server. Can be used for create application tests with memory listener.
Example: listener = bufconn.Listen(1024*1024) tron.New(tron.WithHTTPListener(listener))
func WithLogField ¶
WithLogField adds field to the Logger.
Example: tron.New(tron.WithLogField("my_field_key", "my_field_value"))
func WithPublicGRPC ¶ added in v0.7.0
WithPublicGRPC returns a Option that sets public grpc port. Cannot be changed by config or env.
Example: tron.New(tron.WithPublicGRPC(8082))
func WithPublicHTTP ¶
WithPublicHTTP returns a Option that sets public http port. Cannot be changed by config or env.
Example: tron.New(tron.WithPublicGRPC(8080))
func WithRealtimeConfig ¶ added in v0.8.0
func WithRealtimeConfig() Option
WithRealtimeConfig returns a Option that activate realtime config. Realtime config watch only values file for current namespace.
Example: tron.New(tron.WithRealtimeConfig())
type RunOption ¶
RunOption sets tron run options such as grpc unary interceptors, tls config.
func WithStreamInterceptor ¶ added in v0.13.0
func WithStreamInterceptor(interceptor grpc.StreamServerInterceptor) RunOption
WithStreamInterceptor returns a RunOption that specifies the chained interceptor for streaming RPCs. The first interceptor will be the outer most, while the last interceptor will be the inner most wrapper around the real call. All stream interceptors added by this method will be chained.
func WithTLSConfig ¶
WithTLSConfig returns a RunOption that set tls configuration for grpc and http servers.
func WithTLSKeyPair ¶
WithTLSKeyPair returns a RunOption that set tls configuration for grpc and http servers from files.
func WithUnaryInterceptor ¶
func WithUnaryInterceptor(interceptor grpc.UnaryServerInterceptor) RunOption
WithUnaryInterceptor returns a RunOption that specifies the chained interceptor for unary RPCs. The first interceptor will be the outer most, while the last interceptor will be the inner most wrapper around the real call. All unary interceptors added by this method will be chained.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
protoc-gen-tron
Module
|
|
tron
Module
|
|
example
module
|
|
internal
|
|
admin
Code generated for package admin by go-bindata DO NOT EDIT.
|
Code generated for package admin by go-bindata DO NOT EDIT. |
app
Package app contains base application constants, flags and options.
|
Package app contains base application constants, flags and options. |
config
Package config contains viper config initialisation method.
|
Package config contains viper config initialisation method. |
errors
Package errors represents base tron error struct and parsing method.
|
Package errors represents base tron error struct and parsing method. |
grpc
Package grpc implements an gRPC server.
|
Package grpc implements an gRPC server. |
http
Package http implements an HTTP server.
|
Package http implements an HTTP server. |
Package transport contains base service desc interfaces.
|
Package transport contains base service desc interfaces. |