Documentation ¶
Overview ¶
Package tron contains base application object, some options and functions to create base app.
Index ¶
- func AddLogCaller() app.Option
- func AddLogStacktrace(level string) app.Option
- func SetName(name string)
- func WithAdminHTTP(port uint16) app.Option
- func WithConfigMap(cfg map[string]interface{}) app.Option
- func WithExitSignals(sig ...os.Signal) app.Option
- func WithGRPCListener(listener net.Listener) app.Option
- func WithHTTPListener(listener net.Listener) app.Option
- func WithLogField(key string, value interface{}) app.Option
- func WithPublicGRPC(port uint16) app.Option
- func WithPublicHTTP(port uint16) app.Option
- func WithRealtimeConfig() app.Option
- func WithStreamInterceptor(interceptor grpc.StreamServerInterceptor) app.RunOption
- func WithTLSConfig(config *tls.Config) app.RunOption
- func WithTLSKeyPair(certFile, keyFile string) app.RunOption
- func WithUnaryInterceptor(interceptor grpc.UnaryServerInterceptor) app.RunOption
- type App
- func (a *App) Close()
- func (a *App) Go(f func() error)
- func (a *App) Health() healthcheck.Checker
- func (a *App) Info() *Info
- func (a *App) Logger() *zaplog.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) Wait() error
- func (a *App) WithRunOptions(opts ...app.RunOption) *App
- type Info
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLogCaller ¶
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 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
WithRealtimeConfig returns a Option that activate realtime config. Realtime config watch only values file for current namespace.
Example: tron.New(tron.WithRealtimeConfig())
func WithStreamInterceptor ¶ added in v0.13.0
func WithStreamInterceptor(interceptor grpc.StreamServerInterceptor) app.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) app.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.
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) Go ¶ added in v0.19.1
Go calls the given function in a new goroutine.
The first call to return a non-nil error cancels the group; its error will be returned by Wait.
func (*App) Health ¶ added in v0.14.0
func (a *App) Health() healthcheck.Checker
Health returns application health checker.
func (*App) Router ¶
func (a *App) Router() chi.Router
Router returns http router that runs on public port.
func (*App) TraceLogger ¶
TraceLogger returns wrapped zap logger with opentracing metadata injection to log records.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
protoc-gen-tron
Module
|
|
tron
Module
|
|
example
module
|
|
internal
|
|
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. |