support runtime.ServeMux opts for grpc-gateway
This commit is contained in:
@ -29,6 +29,10 @@ type Opts struct {
|
||||
KeepLast int
|
||||
}
|
||||
|
||||
func (r *WeatherRecorder) Ping(ctx context.Context) error {
|
||||
return r.recorder.Ping(ctx)
|
||||
}
|
||||
|
||||
func MustNewWeatherRecorder(opts *Opts) *WeatherRecorder {
|
||||
if opts.KeepLast < 1 {
|
||||
opts.KeepLast = 1
|
||||
|
@ -25,6 +25,11 @@ type MemoryRecorder struct {
|
||||
*sync.RWMutex
|
||||
}
|
||||
|
||||
// No meaningful health check to do here
|
||||
func (r *MemoryRecorder) Ping(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *MemoryRecorder) Init(ctx context.Context, opts *recorders.RecorderOpts) {
|
||||
if opts.RetainLast < 1 {
|
||||
opts.RetainLast = DEF_RETAIN_LAST
|
||||
|
@ -20,4 +20,6 @@ func (n *NoopRecorder) Get(context.Context, *pb.GetWeatherRequest) ([]*weather.W
|
||||
|
||||
func (n *NoopRecorder) Count(context.Context) int { return 0 }
|
||||
|
||||
func (n *NoopRecorder) Ping(context.Context) error { return nil }
|
||||
|
||||
func (r *NoopRecorder) Name() string { return "no-op recorder" }
|
||||
|
@ -19,5 +19,6 @@ type Recorder interface {
|
||||
Set(context.Context, *weather.WeatherUpdate) error
|
||||
Get(context.Context, *pb.GetWeatherRequest) ([]*weather.WeatherUpdate, error)
|
||||
Count(context.Context) int // Best Effort
|
||||
Ping(context.Context) error
|
||||
Name() string
|
||||
}
|
||||
|
@ -36,6 +36,11 @@ type RedisRecorder struct {
|
||||
*sync.RWMutex
|
||||
}
|
||||
|
||||
func (r *RedisRecorder) Ping(ctx context.Context) error {
|
||||
_, err := r.redis.Ping(ctx).Result()
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *RedisRecorder) Init(ctx context.Context, opts *recorders.RecorderOpts) {
|
||||
if opts.AppConfig.RecorderConfig.RedisConfig == nil {
|
||||
panic("refusing to init redis recorder with no redisConfig")
|
||||
|
Reference in New Issue
Block a user