From 3b3f7f1f8befb27abb66fb5556d419d45848aa10 Mon Sep 17 00:00:00 2001 From: Ryan McGuire Date: Fri, 7 Mar 2025 15:24:36 -0500 Subject: [PATCH] add grpc support --- pkg/config/config_test.go | 8 ++++++++ pkg/config/types_grpc.go | 4 ++++ pkg/config/types_http.go | 21 ++++++++++++--------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index d337a0f..16c88bb 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -22,12 +22,20 @@ var testDefaultConfig = &AppConfig{ TimeFormat: TimeFormatLong, }, HTTP: &HTTPConfig{ + Enabled: true, Listen: "127.0.0.1:8080", LogRequests: false, ReadTimeout: "10s", WriteTimeout: "10s", IdleTimeout: "1m", }, + GRPC: &GRPCConfig{ + Enabled: false, + Listen: "127.0.0.1:8081", + LogRequests: false, + EnableReflection: true, + EnableInstrumentation: true, + }, OTEL: &OTELConfig{ Enabled: true, PrometheusEnabled: true, diff --git a/pkg/config/types_grpc.go b/pkg/config/types_grpc.go index 104f333..4385510 100644 --- a/pkg/config/types_grpc.go +++ b/pkg/config/types_grpc.go @@ -1,12 +1,16 @@ package config var defaultGRPCConfig = &GRPCConfig{ + Enabled: false, + Listen: "127.0.0.1:8081", + LogRequests: false, EnableReflection: true, EnableInstrumentation: true, } type GRPCConfig struct { + Enabled bool `yaml:"enabled" env:"APP_GRPC_ENABLED"` Listen string `yaml:"listen" env:"APP_GRPC_LISTEN"` LogRequests bool `yaml:"logRequests" env:"APP_GRPC_LOG_REQUESTS"` EnableReflection bool `yaml:"enableReflection" env:"APP_GRPC_ENABLE_REFLECTION"` diff --git a/pkg/config/types_http.go b/pkg/config/types_http.go index 3fd2b93..a64944d 100644 --- a/pkg/config/types_http.go +++ b/pkg/config/types_http.go @@ -3,7 +3,9 @@ package config import "time" var defaultHTTPConfig = &HTTPConfig{ - Listen: "127.0.0.1:8080", + Enabled: true, + Listen: "127.0.0.1:8080", + LogRequests: false, ReadTimeout: "10s", WriteTimeout: "10s", @@ -12,12 +14,13 @@ var defaultHTTPConfig = &HTTPConfig{ // HTTP Configuration type HTTPConfig struct { - Listen string `yaml:"listen,omitempty" env:"APP_HTTP_LISTEN"` - LogRequests bool `yaml:"logRequests" env:"APP_HTTP_LOG_REQUESTS"` - ReadTimeout string `yaml:"readTimeout" env:"APP_HTTP_READ_TIMEOUT"` // Go duration (e.g. 10s) - WriteTimeout string `yaml:"writeTimeout" env:"APP_HTTP_WRITE_TIMEOUT"` // Go duration (e.g. 10s) - IdleTimeout string `yaml:"idleTimeout" env:"APP_HTTP_IDLE_TIMEOUT"` // Go duration (e.g. 10s) - rT *time.Duration - wT *time.Duration - iT *time.Duration + Enabled bool `yaml:"enabled" env:"APP_HTTP_ENABLED"` + Listen string `yaml:"listen,omitempty" env:"APP_HTTP_LISTEN"` + LogRequests bool `yaml:"logRequests" env:"APP_HTTP_LOG_REQUESTS"` + ReadTimeout string `yaml:"readTimeout" env:"APP_HTTP_READ_TIMEOUT"` // Go duration (e.g. 10s) + WriteTimeout string `yaml:"writeTimeout" env:"APP_HTTP_WRITE_TIMEOUT"` // Go duration (e.g. 10s) + IdleTimeout string `yaml:"idleTimeout" env:"APP_HTTP_IDLE_TIMEOUT"` // Go duration (e.g. 10s) + rT *time.Duration `yaml:"rT" env:"rT"` + wT *time.Duration `yaml:"wT" env:"wT"` + iT *time.Duration `yaml:"iT" env:"iT"` }