add weather grpc

This commit is contained in:
2025-03-07 08:42:38 -05:00
parent 075902ecd8
commit 81676c5404
9 changed files with 68 additions and 23 deletions

29
pkg/srv/grpc/grpc.go Normal file
View File

@ -0,0 +1,29 @@
package grpc
import (
"context"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"google.golang.org/grpc"
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/grpc/opts"
)
type AppGRPCServer struct {
ctx context.Context
tracer trace.Tracer
meter metric.Meter
}
func InitGRPCServer(ctx context.Context, opts *opts.GRPCOpts) {
server := grpc.NewServer()
stats := otelgrpc.NewServerHandler(otelgrpc.WithTracerProvider(sdktrace.T))
for _, service := range opts.Services {
server.RegisterService(service.Type, service.Service)
}
}

View File

@ -0,0 +1,11 @@
package opts
import (
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/app"
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
)
type GRPCOpts struct {
*config.GRPCConfig
*app.AppGRPC
}

View File

@ -1,4 +1,4 @@
package srv
package http
import (
"context"
@ -128,17 +128,9 @@ func prepHTTPServer(opts *HTTPServerOpts) *http.Server {
}
}
// Returns a shutdown func and a done channel if the
// server aborts abnormally. Panics on error.
func InitHTTPServer(opts *HTTPServerOpts) (
func(context.Context) error, <-chan any, error,
) {
return initHTTPServer(opts)
}
// Returns a shutdown func and a done channel if the
// server aborts abnormally. Returns error on failure to start
func initHTTPServer(opts *HTTPServerOpts) (
func InitHTTPServer(opts *HTTPServerOpts) (
func(context.Context) error, <-chan any, error,
) {
l := zerolog.Ctx(opts.Ctx)

View File

@ -1,4 +1,4 @@
package srv
package http
import (
"context"

View File

@ -1,4 +1,4 @@
package srv
package http
import (
"bytes"