Documentation ¶
Index ¶
- Variables
- func StreamClientLogging(logger log.Logger, withTimer bool) grpc.StreamClientInterceptor
- func StreamClientTiming(logger log.Logger) grpc.StreamClientInterceptor
- func UnaryClientLogging(logger log.Logger, withTimer bool) grpc.UnaryClientInterceptor
- func UnaryClientTiming(logger log.Logger) grpc.UnaryClientInterceptor
- type Backoff
- func (b *Backoff) AddMessage(msg *event.Event)
- func (b *Backoff) BackoffFunc(f BackoffFunc)
- func (b *Backoff) Counter() uint
- func (b *Backoff) Current() string
- func (b *Backoff) IsLocked() bool
- func (b *Backoff) Lock()
- func (b *Backoff) Max() string
- func (b *Backoff) Register(call interface{})
- func (b *Backoff) StreamBackoffHandler(errCh chan error, cancel context.CancelFunc, logger log.Logger, ...)
- func (b *Backoff) Time(t time.Duration)
- func (b *Backoff) TryLock() bool
- func (b *Backoff) UnaryBackoffHandler(err error, logger log.Logger) error
- func (b *Backoff) Unlock()
- func (b *Backoff) Wait() (func(), error)
- func (b *Backoff) WaitContext(ctx context.Context) (func(), error)
- type BackoffFunc
- type GRPCLogClient
- func (c *GRPCLogClient) AddOuts(outs ...io.Writer) log.Logger
- func (c *GRPCLogClient) Channels() (logCh chan *event.Event, done chan struct{})
- func (c *GRPCLogClient) Close()
- func (c *GRPCLogClient) Debug(v ...interface{})
- func (c *GRPCLogClient) Debugf(format string, v ...interface{})
- func (c *GRPCLogClient) Debugln(v ...interface{})
- func (c *GRPCLogClient) Error(v ...interface{})
- func (c *GRPCLogClient) Errorf(format string, v ...interface{})
- func (c *GRPCLogClient) Errorln(v ...interface{})
- func (c *GRPCLogClient) Fatal(v ...interface{})
- func (c *GRPCLogClient) Fatalf(format string, v ...interface{})
- func (c *GRPCLogClient) Fatalln(v ...interface{})
- func (c *GRPCLogClient) Fields(fields map[string]interface{}) log.Logger
- func (c *GRPCLogClient) Info(v ...interface{})
- func (c *GRPCLogClient) Infof(format string, v ...interface{})
- func (c *GRPCLogClient) Infoln(v ...interface{})
- func (c *GRPCLogClient) IsSkipExit() bool
- func (c *GRPCLogClient) Log(m ...*event.Event)
- func (c *GRPCLogClient) Output(m *event.Event) (n int, err error)
- func (c *GRPCLogClient) Panic(v ...interface{})
- func (c *GRPCLogClient) Panicf(format string, v ...interface{})
- func (c *GRPCLogClient) Panicln(v ...interface{})
- func (c *GRPCLogClient) Prefix(prefix string) log.Logger
- func (c *GRPCLogClient) Print(v ...interface{})
- func (c *GRPCLogClient) Printf(format string, v ...interface{})
- func (c *GRPCLogClient) Println(v ...interface{})
- func (c *GRPCLogClient) SetOuts(outs ...io.Writer) log.Logger
- func (c *GRPCLogClient) Sub(sub string) log.Logger
- func (c *GRPCLogClient) Trace(v ...interface{})
- func (c *GRPCLogClient) Tracef(format string, v ...interface{})
- func (c *GRPCLogClient) Traceln(v ...interface{})
- func (c *GRPCLogClient) Warn(v ...interface{})
- func (c *GRPCLogClient) Warnf(format string, v ...interface{})
- func (c *GRPCLogClient) Warnln(v ...interface{})
- func (c *GRPCLogClient) Write(p []byte) (n int, err error)
- type GRPCLogger
- type LSAddr
- type LSExpBackoff
- type LSLogger
- type LSOpts
- type LSStreamInterceptor
- type LSTiming
- type LSType
- type LSUnaryInterceptor
- type LogClientConfig
- func Insecure() LogClientConfig
- func MultiConf(conf ...LogClientConfig) LogClientConfig
- func StreamRPC() LogClientConfig
- func UnaryRPC() LogClientConfig
- func WithAddr(addr ...string) LogClientConfig
- func WithBackoff(deadline time.Duration, backoffFunc BackoffFunc) LogClientConfig
- func WithGRPCOpts(opts ...grpc.DialOption) LogClientConfig
- func WithLogger(loggers ...log.Logger) LogClientConfig
- func WithLoggerV(loggers ...log.Logger) LogClientConfig
- func WithStreamInterceptor(name string, itcp grpc.StreamClientInterceptor) LogClientConfig
- func WithTLS(caPath string, certKeyPair ...string) LogClientConfig
- func WithTiming() LogClientConfig
- func WithUnaryInterceptor(name string, itcp grpc.UnaryClientInterceptor) LogClientConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrFailedRetry error = errors.New("failed to connect to server after numerous retries") ErrFailedConn error = errors.New("failed to connect to server") ErrInvalidType error = errors.New("unsupported exponential backoff function type") ErrBackoffLocked error = errors.New("operations locked during exponential backoff") )
var ( ErrNoAddr error = errors.New("cannot connect to gRPC server since no addresses were provided") ErrNoConns error = errors.New("could not establish any successful connection with the provided address(es)") ErrBadResponse error = errors.New("failed to write log message in remote gRPC server") ErrBadWriter error = errors.New("invalid writer -- must be of type client.ConnAddr") )
var ( ErrCACertAddFailed error = errors.New("failed to add server CA's certificate") ErrEmptyPath error = errors.New("a required path was found to be empty") LogClientConfigs = map[int]LogClientConfig{ 0: defaultConfig, 1: WithBackoff(0, BackoffExponential()), 2: WithBackoff(time.Second*30, BackoffExponential()), } DefaultCfg LogClientConfig = LogClientConfigs[0] // placeholder for an initialized default LogClientConfig BackoffFiveMin LogClientConfig = LogClientConfigs[1] // placeholder for a backoff config with 5-minute deadline BackoffHalfMin LogClientConfig = LogClientConfigs[2] // placeholder for a backoff config with 30-second deadline )
Functions ¶
func StreamClientLogging ¶
func StreamClientLogging(logger log.Logger, withTimer bool) grpc.StreamClientInterceptor
StreamClientLogging returns a new stream client interceptor that adds a gRPC Client Logger which captures inbound / outbound interactions with the service
func StreamClientTiming ¶
func StreamClientTiming(logger log.Logger) grpc.StreamClientInterceptor
StreamClientTiming returns a new stream client interceptor that shows the time taken to complete RPCs
func UnaryClientLogging ¶
func UnaryClientLogging(logger log.Logger, withTimer bool) grpc.UnaryClientInterceptor
UnaryClientLogging returns a new unary client interceptor that adds a gRPC Client Logger which captures inbound / outbound interactions with the service
func UnaryClientTiming ¶
func UnaryClientTiming(logger log.Logger) grpc.UnaryClientInterceptor
UnaryClientTiming returns a new unary client interceptor that shows the time taken to complete RPCs
Types ¶
type Backoff ¶
type Backoff struct {
// contains filtered or unexported fields
}
Backoff struct defines the elements of a backoff module, which is configured by setting a BackoffFunc to define the interval between each attempt.
Backoff will also try to act as a message buffer in case the server connection cannot be established -- as it will attempt to flush these records to the server as soon as connected.
Also it has a simple lock / unlock switch for concurrent calls to be able to verify its state and halt by themselves
func NewBackoff ¶
func NewBackoff() *Backoff
NewBackoff function initializes a simple exponential backoff module with an exponential backoff with set default retry time of 30 seconds
func (*Backoff) AddMessage ¶
AddMessage method will append a new message to the exponential backoff's message queue
func (*Backoff) BackoffFunc ¶
func (b *Backoff) BackoffFunc(f BackoffFunc)
func (*Backoff) Counter ¶
Counter method will return the current amount of retries since the connection failed to be established
func (*Backoff) Current ¶
Current method will return the current ExpBackoff's wait time, in a string format
func (*Backoff) Lock ¶
func (b *Backoff) Lock()
Lock method will set the ExpBackoff's locked element to true, preventing future calls from proceeding.
func (*Backoff) Register ¶
func (b *Backoff) Register(call interface{})
Register method will take in a function with the same signature as a stream() function and the error channel of the gRPC Log Client; and returns a pointer to itself for method chaining
func (*Backoff) StreamBackoffHandler ¶
func (b *Backoff) StreamBackoffHandler( errCh chan error, cancel context.CancelFunc, logger log.Logger, done chan struct{}, )
StreamBackoffHandler method is the Stream gRPC Log Client's standard backoff flow, which is used when setting up a stream and when receiving an error from the gRPC Log Server
func (*Backoff) Time ¶
Time method will set the ExpBackoff's deadline, and returns a pointer to itself for chaining
func (*Backoff) TryLock ¶
TryLock method is similar to the mutex.TryLock() one; to allow checking for a locked status as the method also tries to lock the mutex.
It is used to get a status from the mutex as the call is made.
func (*Backoff) UnaryBackoffHandler ¶
UnaryBackoffHandler method is the Unary gRPC Log Client's standard backoff flow, which is used when exchanging unary requests and responses with a gRPC server.
func (*Backoff) Unlock ¶
func (b *Backoff) Unlock()
Unlock method will set the ExpBackoff's locked element to false, allowing future calls to proceed.
func (*Backoff) Wait ¶
Wait method will wait for the currently set wait time, if the module is unlocked.
After waiting, it returns a func() to call (depending on what it is handling), and and an error.
If the waiting time is grater than the deadline set, it will return with an ErrFailedRetry
func (*Backoff) WaitContext ¶
WaitContext method will wait for the currently set wait time, if the module is unlocked. It also takes in a context, for which it will listen to its Done() signal.
After waiting, it returns a func() to call (depending on what it is handling), and and an error.
If the waiting time is grater than the deadline set, it will return with an ErrFailedRetry
type BackoffFunc ¶
BackoffFunc takes in a(n unsigned) integer representing the attempt counter, and returns a time.Duration value of how much should the module wait before the next attempt / retry
func BackoffExponential ¶
func BackoffExponential() BackoffFunc
BackoffExponential function will return a BackoffFunc that calculates exponential backoff according to its standard
Notes on exponential backoff: https://en.wikipedia.org/wiki/Exponential_backoff
func BackoffIncremental ¶
func BackoffIncremental(scalar time.Duration) BackoffFunc
BackoffIncremental function will return a BackoffFunc that calculates exponential backoff according to a scalar method
func BackoffLinear ¶
func BackoffLinear(t time.Duration) BackoffFunc
BackoffLinear function will return a BackoffFunc that sets a linear backoff according to the input duration. If the input duration is 0, then the default wait-between time is set.
func NoBackoff ¶
func NoBackoff() BackoffFunc
NoBackoff function will return a BackoffFunc that overrides the backoff module by setting a zero wait-between duration. This is detected as a sign that the module should be overriden.
type GRPCLogClient ¶
type GRPCLogClient struct {
// contains filtered or unexported fields
}
GRPCLogClient struct will define the elements required to build and work with a gRPC Log Client.
It does not have exactly the same elements as a joined Logger+ChannelLogger, considering that it is actually sending log messages to a (remote) server that is configuring its own Logger.
func (*GRPCLogClient) AddOuts ¶
func (c *GRPCLogClient) AddOuts(outs ...io.Writer) log.Logger
AddOuts method implements the Logger's AddOuts().
For compatibility with the Logger interface, this method must take in io.Writers. However, this is not how the gRPC Log Client will work to register messages.
As such, the ConnAddr type will implement the Write() method to be compatible with this implementation -- however the type assertion (and check of the same) is required to ensure that only "clean" io.Writers are passed on. If so -- these will be added to the connection/address map. Otherwise a Bad Writer error is returned.
After doing so, the method will run the client's connect() method to ensure these are healthy. If there are errors in this check, the retuning value will be nil instead of the same logger.
AddOuts() will add the new input io.Writers to the existing connections and addresses
func (*GRPCLogClient) Channels ¶
func (c *GRPCLogClient) Channels() (logCh chan *event.Event, done chan struct{})
Channels method is the implementation of the ChanneledLogger's Channels().
It returns two channels (message and done channels) to allow control over the gRPC Log Client over a background / separate goroutine. Considering that creating a gRPC Log Client returns an error channel, this method will give the developer the three needed channels to work with the logger asynchronously
func (*GRPCLogClient) Close ¶
func (c *GRPCLogClient) Close()
Close method is the implementation of the ChanneledLogger's Close().
For a gRPC Log Client, it is important to iterate through all (alive) connections in the ConnAddr map, and close them. After doing so, it sends the done signal to its channel, which causes all open streams to cancel their context and exit gracefully
func (*GRPCLogClient) Debug ¶
func (c *GRPCLogClient) Debug(v ...interface{})
Debug method implements the Printer interface.
It is similar to fmt.Print; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Debug.
func (*GRPCLogClient) Debugf ¶
func (c *GRPCLogClient) Debugf(format string, v ...interface{})
Debugf method implements the Printer interface.
It is similar to fmt.Printf; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Debug.
func (*GRPCLogClient) Debugln ¶
func (c *GRPCLogClient) Debugln(v ...interface{})
Debugln method implements the Printer interface.
It is similar to fmt.Println; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Debug.
func (*GRPCLogClient) Error ¶
func (c *GRPCLogClient) Error(v ...interface{})
Error method implements the Printer interface.
It is similar to fmt.Print; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Error.
func (*GRPCLogClient) Errorf ¶
func (c *GRPCLogClient) Errorf(format string, v ...interface{})
Errorf method implements the Printer interface.
It is similar to fmt.Printf; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Error.
func (*GRPCLogClient) Errorln ¶
func (c *GRPCLogClient) Errorln(v ...interface{})
Errorln method implements the Printer interface.
It is similar to fmt.Println; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Error.
func (*GRPCLogClient) Fatal ¶
func (c *GRPCLogClient) Fatal(v ...interface{})
Fatal method implements the Printer interface.
It is similar to fmt.Print; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Fatal.
func (*GRPCLogClient) Fatalf ¶
func (c *GRPCLogClient) Fatalf(format string, v ...interface{})
Fatalf method implements the Printer interface.
It is similar to fmt.Printf; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Fatal.
func (*GRPCLogClient) Fatalln ¶
func (c *GRPCLogClient) Fatalln(v ...interface{})
Fatalln method implements the Printer interface.
It is similar to fmt.Println; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Fatal.
func (*GRPCLogClient) Fields ¶
func (c *GRPCLogClient) Fields(fields map[string]interface{}) log.Logger
Fields method implements the Logger interface.
Fields method will set Logger-scoped (as opposed to message-scoped) metadata fields to the logger ¶
Logger-scoped metadata can be set in order to avoid caLevel_ing the `MessageBuilder.Metadata()` method repeatedly, and instead doing so via the logger at the beginning of a service or function.
Logger-scoped metadata fields are not cleared with new log messages, but only added to the existing metadata map. These can be cleared with a call to `Logger.Fields(nil)`
func (*GRPCLogClient) Info ¶
func (c *GRPCLogClient) Info(v ...interface{})
Info method implements the Printer interface.
It is similar to fmt.Print; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Info.
func (*GRPCLogClient) Infof ¶
func (c *GRPCLogClient) Infof(format string, v ...interface{})
Infof method implements the Printer interface.
It is similar to fmt.Printf; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Info.
func (*GRPCLogClient) Infoln ¶
func (c *GRPCLogClient) Infoln(v ...interface{})
Infoln method implements the Printer interface.
It is similar to fmt.Println; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Info.
func (*GRPCLogClient) IsSkipExit ¶
func (c *GRPCLogClient) IsSkipExit() bool
IsSkipExit method implements the Printer interface.
IsSkipExit method returns a boolean on whether the gRPC Log Client's service logger is set to skip os.Exit(1) or panic() calls.
It is used in functions which call these, to first evaluate if those calls should be executed or skipped.
Considering this method is unused by the gRPC Log Client, it's merely here to implement the interface
func (*GRPCLogClient) Log ¶
func (c *GRPCLogClient) Log(m ...*event.Event)
Log method implements the Printer interface.
It will take in a pointer to one or more LogMessages, and write it to the Logger's io.Writer without returning an error message.
While the resulting error message of running `GRPCLogClient.Output()` is simply ignored, this is done as a blind-write for this Logger. Since these methods are simply sinking LogMessages to a channel, this operation is considered safe (the errors will be handled at a gRPC Log Client level, not as a Logger)
func (*GRPCLogClient) Output ¶
func (c *GRPCLogClient) Output(m *event.Event) (n int, err error)
Output method implements the Logger's Output().
This method will simply push the incoming Log Message to the message channel, which is sent to a gRPC Log Server, either via a Unary or Stream RPC
func (*GRPCLogClient) Panic ¶
func (c *GRPCLogClient) Panic(v ...interface{})
Panic method implements the Printer interface.
It is similar to fmt.Print; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Panic.
func (*GRPCLogClient) Panicf ¶
func (c *GRPCLogClient) Panicf(format string, v ...interface{})
Panicf method implements the Printer interface.
It is similar to fmt.Printf; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Panic.
func (*GRPCLogClient) Panicln ¶
func (c *GRPCLogClient) Panicln(v ...interface{})
Panicln method implements the Printer interface.
It is similar to fmt.Println; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Panic.
func (*GRPCLogClient) Prefix ¶
func (c *GRPCLogClient) Prefix(prefix string) log.Logger
Prefix method implements the Logger interface.
It will set a Logger-scoped (as opposed to message-scoped) prefix string to the logger ¶
Logger-scoped prefix strings can be set in order to avoid caLevel_ing the `MessageBuilder.Prefix()` method repeatedly, and instead doing so via the logger at the beginning of a service or function
A logger-scoped prefix is not cleared with new Log messages, but `MessageBuilder.Prefix()` calls will replace it.
func (*GRPCLogClient) Print ¶
func (c *GRPCLogClient) Print(v ...interface{})
Print method implements the Printer interface.
It is similar to fmt.Print; and will print a message using an fmt.Sprint(v...) pattern
It applies LogLevel Info
func (*GRPCLogClient) Printf ¶
func (c *GRPCLogClient) Printf(format string, v ...interface{})
Printf method implements the Printer interface.
It is similar to fmt.Printf; and will print a message using an fmt.Sprintf(format, v...) pattern
It applies LogLevel Info
func (*GRPCLogClient) Println ¶
func (c *GRPCLogClient) Println(v ...interface{})
Println method implements the Printer interface.
It is similar to fmt.Println; and will print a message using an fmt.Sprintln(v...) pattern
It applies LogLevel Info
func (*GRPCLogClient) SetOuts ¶
func (c *GRPCLogClient) SetOuts(outs ...io.Writer) log.Logger
SetOuts method implements the Logger's SetOuts().
For compatibility with the Logger interface, this method must take in io.Writers. However, this is not how the gRPC Log Client will work to register messages.
As such, the ConnAddr type will implement the Write() method to be compatible with this implementation -- however the type assertion (and check of the same) is required to ensure that only "clean" io.Writers are passed on. If so -- these will be added to the connection/address map. Otherwise a Bad Writer error is returned.
After doing so, the method will run the client's connect() method to ensure these are healthy. If there are errors in this check, the retuning value will be nil instead of the same logger.
SetOuts() will replace all the existing connections and addresses by resetting the map beforehand.
func (*GRPCLogClient) Sub ¶
func (c *GRPCLogClient) Sub(sub string) log.Logger
Sub method implements the Logger interface.
Logger-scoped sub-prefix strings can be set in order to avoid caLevel_ing the `MessageBuilder.Sub()` method repeatedly, and instead doing so via the logger at the beginning of a service or function
A logger-scoped sub-prefix is not cleared with new Log messages, but `MessageBuilder.Sub()` calls will replace it.
func (*GRPCLogClient) Trace ¶
func (c *GRPCLogClient) Trace(v ...interface{})
Trace method implements the Printer interface.
It is similar to fmt.Print; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Trace.
func (*GRPCLogClient) Tracef ¶
func (c *GRPCLogClient) Tracef(format string, v ...interface{})
Tracef method implements the Printer interface.
It is similar to fmt.Printf; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Trace.
func (*GRPCLogClient) Traceln ¶
func (c *GRPCLogClient) Traceln(v ...interface{})
Traceln method implements the Printer interface.
It is similar to fmt.Println; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Trace.
func (*GRPCLogClient) Warn ¶
func (c *GRPCLogClient) Warn(v ...interface{})
Warn method implements the Printer interface.
It is similar to fmt.Print; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Warn.
func (*GRPCLogClient) Warnf ¶
func (c *GRPCLogClient) Warnf(format string, v ...interface{})
Warnf method implements the Printer interface.
It is similar to fmt.Printf; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Warn.
func (*GRPCLogClient) Warnln ¶
func (c *GRPCLogClient) Warnln(v ...interface{})
Warnln method implements the Printer interface.
It is similar to fmt.Println; and will print a message using an fmt.Sprint(v...) pattern, while automatically applying LogLevel Warn.
func (*GRPCLogClient) Write ¶
func (c *GRPCLogClient) Write(p []byte) (n int, err error)
Write method complies with the Logger's io.Writer implementation.
The Write method will allow adding this Logger as a io.Writer to other objects. Although this is slightly meta (the client is used as a writer to write to the server who will write the log message -- plus the internal logging events for these loggers) it is still possible, if you really want to use it that way
Added bonus is support for gob-encoded messages, which is also natively supported in the logger's Write implementation
type GRPCLogger ¶
type GRPCLogger interface { log.Logger logch.ChanneledLogger }
GRPCLogger interface will be of types Logger and ChanneledLogger, to allow it being used interchangeably as either, with the same methods and API
In nature, it is a gRPC client for a gRPC Log Server. As such, certain configurations are inaccessible as they are set on the server (e.g., IsSkipExit())
Also worth mentioning that MultiLogger() will support Loggers of this type, considering that its SetOuts() / AddOuts() methods are expecting an io.Writer of type ConnAddr
func MultiLogger ¶
func MultiLogger(loggers ...GRPCLogger) GRPCLogger
MultiLogger function is a wrapper for multiple GRPCLogger
Similar to how io.MultiWriter() is implemented, this function generates a single GRPCLogger that targets a set of configured GRPCLogger.
As such, a single GRPCLogger can have multiple GRPCLoggers with different configurations and output addresses, while still registering the same log message.
func New ¶
func New(opts ...LogClientConfig) (GRPCLogger, chan error)
New function will serve as a GRPCLogger factory -- taking in different LogClientConfig options and creating either a Unary RPC or a Stream RPC GRPCLogger, along with other user-defined (or default) parameters
This function returns not only the logger but an error channel, which should be monitored (preferrably in a goroutine) to ensure that the gRPC client is running without issues
func NilClient ¶
func NilClient() GRPCLogger
type LSAddr ¶
type LSAddr struct {
// contains filtered or unexported fields
}
LSAddr struct is a custom LogClientConfig to define addresses to new gRPC Log Client
type LSExpBackoff ¶
type LSExpBackoff struct {
// contains filtered or unexported fields
}
LSExpBackoff struct is a custom LogClientConfig to define the backoff configuration for the new gRPC Log Client
func (LSExpBackoff) Apply ¶
func (l LSExpBackoff) Apply(ls *gRPCLogClientBuilder)
Apply method will set this option's backoff as the input gRPCLogClientBuilder's
type LSLogger ¶
type LSLogger struct {
// contains filtered or unexported fields
}
LSLogger struct is a custom LogClientConfig to define the service logger for the new gRPC Log Client
type LSOpts ¶
type LSOpts struct {
// contains filtered or unexported fields
}
LSOpts struct is a custom LogClientConfig to define gRPC Dial Options to new gRPC Log Client
type LSStreamInterceptor ¶
type LSStreamInterceptor struct {
// contains filtered or unexported fields
}
LSStreamInterceptor struct is a custom LogClientConfig to define a custom interceptor
func (LSStreamInterceptor) Apply ¶
func (l LSStreamInterceptor) Apply(ls *gRPCLogClientBuilder)
Apply method will set this option's Stream interceptor on the gRPCLogClientBuilder
type LSTiming ¶
type LSTiming struct{}
LSTiming struct is a custom LogClientConfig to add (debug) information on time taken to execute RPCs.
type LSType ¶
type LSType struct {
// contains filtered or unexported fields
}
LSType struct is a custom LogClientConfig to define the type of a new gRPC Log Client (unary or stream)
type LSUnaryInterceptor ¶
type LSUnaryInterceptor struct {
// contains filtered or unexported fields
}
LSUnaryInterceptor struct is a custom LogClientConfig to define a custom interceptor
func (LSUnaryInterceptor) Apply ¶
func (l LSUnaryInterceptor) Apply(ls *gRPCLogClientBuilder)
Apply method will set this option's Unary interceptor on the gRPCLogClientBuilder
type LogClientConfig ¶
type LogClientConfig interface {
Apply(ls *gRPCLogClientBuilder)
}
LogClientConfig interface describes the behavior that a LogClientConfig object should have
The single Apply(lb *GRPCLogClientBuilder) method allows for different modules to apply changes to a GRPCLogClientBuilder, in a non-blocking way for other features.
Each feature should implement its own structs with their own methods; where they can implement Apply(lb *GRPCLogClientBuilder) to set their own configurations to the input GRPCLogClientBuilder
func Insecure ¶
func Insecure() LogClientConfig
Insecure function will allow creating an insecure gRPC connection (maybe for testing purposes) by adding a new option for insecure transport credentials.
func MultiConf ¶
func MultiConf(conf ...LogClientConfig) LogClientConfig
MultiConf function is a wrapper for multiple configs to be bundled (and executed) in one shot.
Similar to io.MultiWriter, it will iterate through all set LogClientConfig and run the same method on each of them.
func StreamRPC ¶
func StreamRPC() LogClientConfig
StreamRPC function will set this gRPC Log Client type as Stream RPC
func UnaryRPC ¶
func UnaryRPC() LogClientConfig
UnaryRPC function will set this gRPC Log Client type as Unary RPC
func WithAddr ¶
func WithAddr(addr ...string) LogClientConfig
WithAddr function will take in any amount of addresses, and create a connections map with them, for the gRPC client to connect to the server
If these addresses are all empty (or if none is provided) defaults are applied (localhost:9099)
func WithBackoff ¶
func WithBackoff(deadline time.Duration, backoffFunc BackoffFunc) LogClientConfig
WithBackoff function will take in a time.Duration value to set as the exponential backoff module's retry deadline, and a BackoffFunc to customize the backoff pattern
If deadline is set to 0 and no BackoffFunc is provided, then no backoff logic is applied.
Otherwise, defaults are set:
- if a BackoffFunc is set but deadline is zero: default retry time is set
- if no BackoffFunc is provided, but a deadline is set: Exponential with input deadline.
func WithGRPCOpts ¶
func WithGRPCOpts(opts ...grpc.DialOption) LogClientConfig
WithGRPCOpts will allow passing in any number of gRPC Dial Options, which are added to the gRPC Log Client.
Running this function with zero parameters will generate a LogClientConfig with the default gRPC Dial Options.
func WithLogger ¶
func WithLogger(loggers ...log.Logger) LogClientConfig
WithLogger function will define this gRPC Log Client's service logger. This logger will register the gRPC Client transactions; and not the log messages it is handling.
This function's loggers input parameter is variadic -- it supports setting any number of loggers. If no input is provided, then it will default to setting this service logger as a nil logger (one which doesn't do anything)
This function configures the gRPC client's logger interceptors
func WithLoggerV ¶
func WithLoggerV(loggers ...log.Logger) LogClientConfig
WithLogger function will define this gRPC Log Client's service logger, in verbose mode. This logger will register the gRPC Client transactions; and not the log messages it is handling.
This function's loggers input parameter is variadic -- it supports setting any number of loggers. If no input is provided, then it will default to setting this service logger as a nil logger (one which doesn't do anything)
This function configures the gRPC client's logger interceptors
func WithStreamInterceptor ¶
func WithStreamInterceptor(name string, itcp grpc.StreamClientInterceptor) LogClientConfig
WithStreamInterceptor function creates a new Stream interceptor config, based on the input interceptor, mapped to the input name. Note that depending of the order of the chanining and naming, this may overwrite other existing interceptors.
func WithTLS ¶
func WithTLS(caPath string, certKeyPair ...string) LogClientConfig
WithTLS function allows configuring TLS / mTLS for a gRPC Log Client.
If only one parameter is passed (caPath), it will run its TLS flow. If three parameters are set (caPath, certPath, keyPath), it will run its mTLS flow.
The function will try to open the certificates that the user points to in these paths, so it is required that they are accessible in terms of permissions. These configurations will panic if they fail to execute. This is OK since it should happen as soon as the client is executed.
func WithTiming ¶
func WithTiming() LogClientConfig
WithTiming function will set a gRPC Log Client's service logger to measure the time taken when executing RPCs. It is only an option, and is directly tied to the configured service logger.
Since defaults are enforced, the service logger value is never nil.
This function configures the gRPC client's timer interceptors
func WithUnaryInterceptor ¶
func WithUnaryInterceptor(name string, itcp grpc.UnaryClientInterceptor) LogClientConfig
WithUnaryInterceptor function creates a new Unary interceptor config, based on the input interceptor, mapped to the input name. Note that depending of the order of the chanining and naming, this may overwrite other existing interceptors.