Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func OTELMeterProvider() otelmetric.MeterProvider
OTELMeterProvider returns the global OTel MeterProvider. This is a convenience accessor for code that needs the interface type.

<a name="SetOTELGRPCClientOptions"></a>
## func [SetOTELGRPCClientOptions](<https://github.com/go-coldbrew/core/blob/main/core.go#L575>)
## func [SetOTELGRPCClientOptions](<https://github.com/go-coldbrew/core/blob/main/core.go#L594>)

```go
func SetOTELGRPCClientOptions(opts ...otelgrpc.Option)
Expand All @@ -146,7 +146,7 @@ func SetOTELGRPCClientOptions(opts ...otelgrpc.Option)
Deprecated: Use SetOTELOptions instead. Only applies when OTEL\_USE\_LEGACY\_INSTRUMENTATION=true.

<a name="SetOTELGRPCServerOptions"></a>
## func [SetOTELGRPCServerOptions](<https://github.com/go-coldbrew/core/blob/main/core.go#L569>)
## func [SetOTELGRPCServerOptions](<https://github.com/go-coldbrew/core/blob/main/core.go#L588>)

```go
func SetOTELGRPCServerOptions(opts ...otelgrpc.Option)
Expand All @@ -155,7 +155,7 @@ func SetOTELGRPCServerOptions(opts ...otelgrpc.Option)
Deprecated: Use SetOTELOptions instead. Only applies when OTEL\_USE\_LEGACY\_INSTRUMENTATION=true.

<a name="SetOTELOptions"></a>
## func [SetOTELOptions](<https://github.com/go-coldbrew/core/blob/main/core.go#L582>)
## func [SetOTELOptions](<https://github.com/go-coldbrew/core/blob/main/core.go#L601>)

```go
func SetOTELOptions(opts grpcotel.Options)
Expand Down Expand Up @@ -314,7 +314,7 @@ type CB interface {
```

<a name="New"></a>
### func [New](<https://github.com/go-coldbrew/core/blob/main/core.go#L895>)
### func [New](<https://github.com/go-coldbrew/core/blob/main/core.go#L914>)

```go
func New(c config.Config) CB
Expand Down
20 changes: 14 additions & 6 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import "github.com/go-coldbrew/core/config"


<a name="Config"></a>
## type [Config](<https://github.com/go-coldbrew/core/blob/main/config/config.go#L6-L174>)
## type [Config](<https://github.com/go-coldbrew/core/blob/main/config/config.go#L12-L188>)

Config is the configuration for the Coldbrew server It is populated from environment variables and has sensible defaults for all fields so that you can just use it as is without any configuration The following environment variables are supported and can be used to override the defaults for the fields

Expand Down Expand Up @@ -174,13 +174,21 @@ type Config struct {
// DisableProtoValidate disables the protovalidate interceptor in the default
// interceptor chain. When disabled, proto validation annotations are ignored.
DisableProtoValidate bool `envconfig:"DISABLE_PROTO_VALIDATE" default:"false"`
// DisableDebugLogInterceptor disables the DebugLogInterceptor in the default
// interceptor chain. When disabled, proto debug fields and metadata headers
// will not trigger per-request debug logging.
DisableDebugLogInterceptor bool `envconfig:"DISABLE_DEBUG_LOG_INTERCEPTOR" default:"false"`
// DebugLogHeaderName is the gRPC metadata / HTTP header name that triggers
// per-request debug logging. The header value should be a valid log level
// (e.g., "debug"). Default: "x-debug-log-level".
DebugLogHeaderName string `envconfig:"DEBUG_LOG_HEADER_NAME" default:"x-debug-log-level"`
// DisableVTProtobuf disables the use of the vtprotobuf marshaller and unmarshaller for GRPC
// https://github.com/planetscale/vtprotobuf
DisableVTProtobuf bool `envconfig:"DISABLE_VT_PROTOBUF" default:"false"`
// GRPCMaxSendMsgSize and GRPCMaxRecvMsgSize are the maximum message
// sizes for sending and receiving messages over GRPC
GRPCMaxSendMsgSize int `envconfig:"GRPC_MAX_SEND_MSG_SIZE" default:"2147483647"` // Unlimited
GRPCMaxRecvMsgSize int `envconfig:"GRPC_MAX_RECV_MSG_SIZE" default:"4194304"` // 4MB
// GRPCMaxSendMsgSize is the max response size your service can send back to clients.
GRPCMaxSendMsgSize int `envconfig:"GRPC_MAX_SEND_MSG_SIZE" default:"2147483647"` // ~2GB (gRPC maximum)
// GRPCMaxRecvMsgSize is the max request size your service accepts from clients.
GRPCMaxRecvMsgSize int `envconfig:"GRPC_MAX_RECV_MSG_SIZE" default:"4194304"` // 4MB
// GRPCServerDefaultTimeoutInSeconds is the default timeout (in seconds) for
// incoming unary gRPC requests that arrive without a deadline. Set to 0 to
// disable. Does not apply to stream RPCs.
Expand Down Expand Up @@ -238,7 +246,7 @@ type Config struct {
```

<a name="Config.Validate"></a>
### func \(Config\) [Validate](<https://github.com/go-coldbrew/core/blob/main/config/config.go#L179>)
### func \(Config\) [Validate](<https://github.com/go-coldbrew/core/blob/main/config/config.go#L193>)

```go
func (c Config) Validate() []string
Expand Down
8 changes: 4 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ type Config struct {
// DisableVTProtobuf disables the use of the vtprotobuf marshaller and unmarshaller for GRPC
// https://github.com/planetscale/vtprotobuf
DisableVTProtobuf bool `envconfig:"DISABLE_VT_PROTOBUF" default:"false"`
// GRPCMaxSendMsgSize and GRPCMaxRecvMsgSize are the maximum message
// sizes for sending and receiving messages over GRPC
GRPCMaxSendMsgSize int `envconfig:"GRPC_MAX_SEND_MSG_SIZE" default:"2147483647"` // Unlimited
GRPCMaxRecvMsgSize int `envconfig:"GRPC_MAX_RECV_MSG_SIZE" default:"4194304"` // 4MB
// GRPCMaxSendMsgSize is the max response size your service can send back to clients.
GRPCMaxSendMsgSize int `envconfig:"GRPC_MAX_SEND_MSG_SIZE" default:"2147483647"` // ~2GB (gRPC maximum)
// GRPCMaxRecvMsgSize is the max request size your service accepts from clients.
GRPCMaxRecvMsgSize int `envconfig:"GRPC_MAX_RECV_MSG_SIZE" default:"4194304"` // 4MB
// GRPCServerDefaultTimeoutInSeconds is the default timeout (in seconds) for
// incoming unary gRPC requests that arrive without a deadline. Set to 0 to
// disable. Does not apply to stream RPCs.
Expand Down
10 changes: 8 additions & 2 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,12 @@ func getCustomHeaderMatcher(prefixes []string, headers ...string) func(string) (
lowerHeaders = append(lowerHeaders, strings.ToLower(h))
}
}
lowerPrefixes := make([]string, 0, len(prefixes))
for _, p := range prefixes {
if p != "" {
lowerPrefixes = append(lowerPrefixes, strings.ToLower(p))
}
}
return func(key string) (string, bool) {
key = strings.ToLower(key)

Expand All @@ -413,8 +419,8 @@ func getCustomHeaderMatcher(prefixes []string, headers ...string) func(string) (
return key, true
}
}
for _, prefix := range prefixes {
if len(prefix) > 0 && strings.HasPrefix(key, strings.ToLower(prefix)) {
for _, prefix := range lowerPrefixes {
if strings.HasPrefix(key, prefix) {
return key, true
}
}
Expand Down
Loading