mirror of
https://github.com/zrepl/zrepl.git
synced 2025-08-09 23:17:35 +02:00
rpc rewrite: control RPCs using gRPC + separate RPC for data transfer
transport/ssh: update go-netssh to new version => supports CloseWrite and Deadlines => build: require Go 1.11 (netssh requires it)
This commit is contained in:
34
rpc/rpc_logging.go
Normal file
34
rpc/rpc_logging.go
Normal file
@ -0,0 +1,34 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zrepl/zrepl/logger"
|
||||
)
|
||||
|
||||
type Logger = logger.Logger
|
||||
|
||||
type contextKey int
|
||||
|
||||
const (
|
||||
contextKeyLoggers contextKey = iota
|
||||
contextKeyGeneralLogger
|
||||
contextKeyControlLogger
|
||||
contextKeyDataLogger
|
||||
)
|
||||
|
||||
/// All fields must be non-nil
|
||||
type Loggers struct {
|
||||
General Logger
|
||||
Control Logger
|
||||
Data Logger
|
||||
}
|
||||
|
||||
func WithLoggers(ctx context.Context, loggers Loggers) context.Context {
|
||||
ctx = context.WithValue(ctx, contextKeyLoggers, loggers)
|
||||
return ctx
|
||||
}
|
||||
|
||||
func GetLoggersOrPanic(ctx context.Context) Loggers {
|
||||
return ctx.Value(contextKeyLoggers).(Loggers)
|
||||
}
|
Reference in New Issue
Block a user