mirror of
https://github.com/rodneyosodo/gophercon-africa-2024.git
synced 2026-06-23 04:10:06 +00:00
feat(calculator): Add initial implementation of calc service
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
This commit is contained in:
@@ -30,3 +30,4 @@ linters:
|
||||
- nonamedreturns
|
||||
- cyclop
|
||||
- errorlint
|
||||
- err113
|
||||
|
||||
@@ -44,9 +44,17 @@ docker: build
|
||||
docker-push: docker
|
||||
$(call docker_push)
|
||||
|
||||
.PHONY: run-binary
|
||||
run-binary:
|
||||
@go run cmd/main.go
|
||||
|
||||
.PHONY: proto
|
||||
proto:
|
||||
@protoc -I. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative calculator/calculator.proto
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
golangci-lint run --config .golangci.yaml
|
||||
@golangci-lint run --config .golangci.yaml
|
||||
|
||||
.PHONY: all
|
||||
all: build docker
|
||||
@@ -58,6 +66,8 @@ help:
|
||||
@echo " make build - Build the binary"
|
||||
@echo " make docker - Build the docker image"
|
||||
@echo " make docker-push - Push the docker image"
|
||||
@echo " make run-binary - Run the binary"
|
||||
@echo " make proto - Generate protobuf files"
|
||||
@echo " make lint - Lint the code"
|
||||
@echo " make all - Build the binary and docker image"
|
||||
@echo " make clean - Clean the build directory"
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rodneyosodo/gophercon/calculator"
|
||||
)
|
||||
|
||||
var _ calculator.CalculatorServer = (*grpcServer)(nil)
|
||||
|
||||
type grpcServer struct {
|
||||
calculator.UnimplementedCalculatorServer
|
||||
service calculator.Service
|
||||
}
|
||||
|
||||
func NewGrpcServer(service calculator.Service) calculator.CalculatorServer {
|
||||
return &grpcServer{service: service}
|
||||
}
|
||||
|
||||
func (s *grpcServer) Add(ctx context.Context, req *calculator.Request) (*calculator.Response, error) {
|
||||
result, err := s.service.Add(ctx, req.GetA(), req.GetB())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &calculator.Response{Result: result}, nil
|
||||
}
|
||||
|
||||
func (s *grpcServer) Subtract(ctx context.Context, req *calculator.Request) (*calculator.Response, error) {
|
||||
result, err := s.service.Subtract(ctx, req.GetA(), req.GetB())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &calculator.Response{Result: result}, nil
|
||||
}
|
||||
|
||||
func (s *grpcServer) Multiply(ctx context.Context, req *calculator.Request) (*calculator.Response, error) {
|
||||
result, err := s.service.Multiply(ctx, req.GetA(), req.GetB())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &calculator.Response{Result: result}, nil
|
||||
}
|
||||
|
||||
func (s *grpcServer) Divide(ctx context.Context, req *calculator.Request) (*calculator.Response, error) {
|
||||
result, err := s.service.Divide(ctx, req.GetA(), req.GetB())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &calculator.Response{Result: result}, nil
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package calculator
|
||||
|
||||
import "context"
|
||||
|
||||
// Service is the interface for the calculator service.
|
||||
// It defines the operations that can be performed on the calculator.
|
||||
// These include addition, subtraction, multiplication, and division.
|
||||
type Service interface {
|
||||
Add(ctx context.Context, a, b int64) (int64, error)
|
||||
Subtract(ctx context.Context, a, b int64) (int64, error)
|
||||
Multiply(ctx context.Context, a, b int64) (int64, error)
|
||||
Divide(ctx context.Context, a, b int64) (int64, error)
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.28.2
|
||||
// source: calculator/calculator.proto
|
||||
|
||||
package calculator
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
A int64 `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"`
|
||||
B int64 `protobuf:"varint,2,opt,name=b,proto3" json:"b,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Request) Reset() {
|
||||
*x = Request{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_calculator_calculator_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Request) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Request) ProtoMessage() {}
|
||||
|
||||
func (x *Request) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_calculator_calculator_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Request.ProtoReflect.Descriptor instead.
|
||||
func (*Request) Descriptor() ([]byte, []int) {
|
||||
return file_calculator_calculator_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Request) GetA() int64 {
|
||||
if x != nil {
|
||||
return x.A
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Request) GetB() int64 {
|
||||
if x != nil {
|
||||
return x.B
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Result int64 `protobuf:"varint,1,opt,name=result,proto3" json:"result,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Response) Reset() {
|
||||
*x = Response{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_calculator_calculator_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Response) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Response) ProtoMessage() {}
|
||||
|
||||
func (x *Response) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_calculator_calculator_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Response.ProtoReflect.Descriptor instead.
|
||||
func (*Response) Descriptor() ([]byte, []int) {
|
||||
return file_calculator_calculator_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *Response) GetResult() int64 {
|
||||
if x != nil {
|
||||
return x.Result
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_calculator_calculator_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_calculator_calculator_proto_rawDesc = []byte{
|
||||
0x0a, 0x1b, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2f, 0x63, 0x61, 0x6c,
|
||||
0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x63,
|
||||
0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x25, 0x0a, 0x07, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x12, 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x01, 0x61, 0x12, 0x0c, 0x0a, 0x01, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x01, 0x62,
|
||||
0x22, 0x22, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x72, 0x65,
|
||||
0x73, 0x75, 0x6c, 0x74, 0x32, 0xe1, 0x01, 0x0a, 0x0a, 0x43, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61,
|
||||
0x74, 0x6f, 0x72, 0x12, 0x30, 0x0a, 0x03, 0x41, 0x64, 0x64, 0x12, 0x13, 0x2e, 0x63, 0x61, 0x6c,
|
||||
0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x14, 0x2e, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x53, 0x75, 0x62, 0x74, 0x72, 0x61, 0x63,
|
||||
0x74, 0x12, 0x13, 0x2e, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61,
|
||||
0x74, 0x6f, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08,
|
||||
0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x79, 0x12, 0x13, 0x2e, 0x63, 0x61, 0x6c, 0x63, 0x75,
|
||||
0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e,
|
||||
0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x44, 0x69, 0x76, 0x69, 0x64, 0x65, 0x12, 0x13, 0x2e,
|
||||
0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x14, 0x2e, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x63, 0x61,
|
||||
0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_calculator_calculator_proto_rawDescOnce sync.Once
|
||||
file_calculator_calculator_proto_rawDescData = file_calculator_calculator_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_calculator_calculator_proto_rawDescGZIP() []byte {
|
||||
file_calculator_calculator_proto_rawDescOnce.Do(func() {
|
||||
file_calculator_calculator_proto_rawDescData = protoimpl.X.CompressGZIP(file_calculator_calculator_proto_rawDescData)
|
||||
})
|
||||
return file_calculator_calculator_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_calculator_calculator_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_calculator_calculator_proto_goTypes = []any{
|
||||
(*Request)(nil), // 0: calculator.Request
|
||||
(*Response)(nil), // 1: calculator.Response
|
||||
}
|
||||
var file_calculator_calculator_proto_depIdxs = []int32{
|
||||
0, // 0: calculator.Calculator.Add:input_type -> calculator.Request
|
||||
0, // 1: calculator.Calculator.Subtract:input_type -> calculator.Request
|
||||
0, // 2: calculator.Calculator.Multiply:input_type -> calculator.Request
|
||||
0, // 3: calculator.Calculator.Divide:input_type -> calculator.Request
|
||||
1, // 4: calculator.Calculator.Add:output_type -> calculator.Response
|
||||
1, // 5: calculator.Calculator.Subtract:output_type -> calculator.Response
|
||||
1, // 6: calculator.Calculator.Multiply:output_type -> calculator.Response
|
||||
1, // 7: calculator.Calculator.Divide:output_type -> calculator.Response
|
||||
4, // [4:8] is the sub-list for method output_type
|
||||
0, // [0:4] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_calculator_calculator_proto_init() }
|
||||
func file_calculator_calculator_proto_init() {
|
||||
if File_calculator_calculator_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_calculator_calculator_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Request); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_calculator_calculator_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Response); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_calculator_calculator_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_calculator_calculator_proto_goTypes,
|
||||
DependencyIndexes: file_calculator_calculator_proto_depIdxs,
|
||||
MessageInfos: file_calculator_calculator_proto_msgTypes,
|
||||
}.Build()
|
||||
File_calculator_calculator_proto = out.File
|
||||
file_calculator_calculator_proto_rawDesc = nil
|
||||
file_calculator_calculator_proto_goTypes = nil
|
||||
file_calculator_calculator_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package calculator;
|
||||
|
||||
option go_package = "./calculator";
|
||||
|
||||
// Calculator is the service that performs arithmetic operations.
|
||||
service Calculator {
|
||||
rpc Add(Request) returns (Response);
|
||||
rpc Subtract(Request) returns (Response);
|
||||
rpc Multiply(Request) returns (Response);
|
||||
rpc Divide(Request) returns (Response);
|
||||
}
|
||||
|
||||
message Request {
|
||||
int64 a = 1;
|
||||
int64 b = 2;
|
||||
}
|
||||
|
||||
message Response { int64 result = 1; }
|
||||
@@ -0,0 +1,228 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.4.0
|
||||
// - protoc v5.28.2
|
||||
// source: calculator/calculator.proto
|
||||
|
||||
package calculator
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.62.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion8
|
||||
|
||||
const (
|
||||
Calculator_Add_FullMethodName = "/calculator.Calculator/Add"
|
||||
Calculator_Subtract_FullMethodName = "/calculator.Calculator/Subtract"
|
||||
Calculator_Multiply_FullMethodName = "/calculator.Calculator/Multiply"
|
||||
Calculator_Divide_FullMethodName = "/calculator.Calculator/Divide"
|
||||
)
|
||||
|
||||
// CalculatorClient is the client API for Calculator service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// Calculator is the service that performs arithmetic operations.
|
||||
type CalculatorClient interface {
|
||||
Add(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
|
||||
Subtract(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
|
||||
Multiply(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
|
||||
Divide(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
|
||||
}
|
||||
|
||||
type calculatorClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewCalculatorClient(cc grpc.ClientConnInterface) CalculatorClient {
|
||||
return &calculatorClient{cc}
|
||||
}
|
||||
|
||||
func (c *calculatorClient) Add(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Response)
|
||||
err := c.cc.Invoke(ctx, Calculator_Add_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *calculatorClient) Subtract(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Response)
|
||||
err := c.cc.Invoke(ctx, Calculator_Subtract_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *calculatorClient) Multiply(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Response)
|
||||
err := c.cc.Invoke(ctx, Calculator_Multiply_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *calculatorClient) Divide(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Response)
|
||||
err := c.cc.Invoke(ctx, Calculator_Divide_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// CalculatorServer is the server API for Calculator service.
|
||||
// All implementations must embed UnimplementedCalculatorServer
|
||||
// for forward compatibility
|
||||
//
|
||||
// Calculator is the service that performs arithmetic operations.
|
||||
type CalculatorServer interface {
|
||||
Add(context.Context, *Request) (*Response, error)
|
||||
Subtract(context.Context, *Request) (*Response, error)
|
||||
Multiply(context.Context, *Request) (*Response, error)
|
||||
Divide(context.Context, *Request) (*Response, error)
|
||||
mustEmbedUnimplementedCalculatorServer()
|
||||
}
|
||||
|
||||
// UnimplementedCalculatorServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedCalculatorServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedCalculatorServer) Add(context.Context, *Request) (*Response, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Add not implemented")
|
||||
}
|
||||
func (UnimplementedCalculatorServer) Subtract(context.Context, *Request) (*Response, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Subtract not implemented")
|
||||
}
|
||||
func (UnimplementedCalculatorServer) Multiply(context.Context, *Request) (*Response, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Multiply not implemented")
|
||||
}
|
||||
func (UnimplementedCalculatorServer) Divide(context.Context, *Request) (*Response, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Divide not implemented")
|
||||
}
|
||||
func (UnimplementedCalculatorServer) mustEmbedUnimplementedCalculatorServer() {}
|
||||
|
||||
// UnsafeCalculatorServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to CalculatorServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeCalculatorServer interface {
|
||||
mustEmbedUnimplementedCalculatorServer()
|
||||
}
|
||||
|
||||
func RegisterCalculatorServer(s grpc.ServiceRegistrar, srv CalculatorServer) {
|
||||
s.RegisterService(&Calculator_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Calculator_Add_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Request)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CalculatorServer).Add(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Calculator_Add_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CalculatorServer).Add(ctx, req.(*Request))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Calculator_Subtract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Request)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CalculatorServer).Subtract(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Calculator_Subtract_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CalculatorServer).Subtract(ctx, req.(*Request))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Calculator_Multiply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Request)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CalculatorServer).Multiply(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Calculator_Multiply_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CalculatorServer).Multiply(ctx, req.(*Request))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Calculator_Divide_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Request)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CalculatorServer).Divide(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Calculator_Divide_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CalculatorServer).Divide(ctx, req.(*Request))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Calculator_ServiceDesc is the grpc.ServiceDesc for Calculator service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Calculator_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "calculator.Calculator",
|
||||
HandlerType: (*CalculatorServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Add",
|
||||
Handler: _Calculator_Add_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Subtract",
|
||||
Handler: _Calculator_Subtract_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Multiply",
|
||||
Handler: _Calculator_Multiply_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Divide",
|
||||
Handler: _Calculator_Divide_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "calculator/calculator.proto",
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/rodneyosodo/gophercon/calculator"
|
||||
)
|
||||
|
||||
var _ calculator.Service = (*logging)(nil)
|
||||
|
||||
type logging struct {
|
||||
logger *slog.Logger
|
||||
svc calculator.Service
|
||||
}
|
||||
|
||||
func Logging(logger *slog.Logger, svc calculator.Service) calculator.Service {
|
||||
return &logging{
|
||||
logger: logger,
|
||||
svc: svc,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *logging) Add(ctx context.Context, a, b int64) (result int64, err error) {
|
||||
defer func(begin time.Time) {
|
||||
args := []any{
|
||||
slog.String("duration", time.Since(begin).String()),
|
||||
slog.Int64("a", a),
|
||||
slog.Int64("b", b),
|
||||
}
|
||||
|
||||
switch err {
|
||||
case nil:
|
||||
l.logger.InfoContext(ctx, "Add completed successfully", args...)
|
||||
default:
|
||||
args = append(args, slog.String("error", err.Error()))
|
||||
l.logger.WarnContext(ctx, "Add failed", args...)
|
||||
}
|
||||
}(time.Now())
|
||||
|
||||
return l.svc.Add(ctx, a, b)
|
||||
}
|
||||
|
||||
func (l *logging) Subtract(ctx context.Context, a, b int64) (result int64, err error) {
|
||||
defer func(begin time.Time) {
|
||||
args := []any{
|
||||
slog.String("duration", time.Since(begin).String()),
|
||||
slog.Int64("a", a),
|
||||
slog.Int64("b", b),
|
||||
}
|
||||
|
||||
switch err {
|
||||
case nil:
|
||||
l.logger.InfoContext(ctx, "Subtract completed successfully", args...)
|
||||
default:
|
||||
args = append(args, slog.String("error", err.Error()))
|
||||
l.logger.WarnContext(ctx, "Subtract failed", args...)
|
||||
}
|
||||
}(time.Now())
|
||||
|
||||
return l.svc.Subtract(ctx, a, b)
|
||||
}
|
||||
|
||||
func (l *logging) Multiply(ctx context.Context, a, b int64) (result int64, err error) {
|
||||
defer func(begin time.Time) {
|
||||
args := []any{
|
||||
slog.String("duration", time.Since(begin).String()),
|
||||
slog.Int64("a", a),
|
||||
slog.Int64("b", b),
|
||||
}
|
||||
|
||||
switch err {
|
||||
case nil:
|
||||
l.logger.InfoContext(ctx, "Multiply completed successfully", args...)
|
||||
default:
|
||||
args = append(args, slog.String("error", err.Error()))
|
||||
l.logger.WarnContext(ctx, "Multiply failed", args...)
|
||||
}
|
||||
}(time.Now())
|
||||
|
||||
return l.svc.Multiply(ctx, a, b)
|
||||
}
|
||||
|
||||
func (l *logging) Divide(ctx context.Context, a, b int64) (result int64, err error) {
|
||||
defer func(begin time.Time) {
|
||||
args := []any{
|
||||
slog.String("duration", time.Since(begin).String()),
|
||||
slog.Int64("a", a),
|
||||
slog.Int64("b", b),
|
||||
}
|
||||
|
||||
switch err {
|
||||
case nil:
|
||||
l.logger.InfoContext(ctx, "Divide completed successfully", args...)
|
||||
default:
|
||||
args = append(args, slog.String("error", err.Error()))
|
||||
l.logger.WarnContext(ctx, "Divide failed", args...)
|
||||
}
|
||||
}(time.Now())
|
||||
|
||||
return l.svc.Divide(ctx, a, b)
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rodneyosodo/gophercon/calculator"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
var _ calculator.Service = (*tracing)(nil)
|
||||
|
||||
type tracing struct {
|
||||
tracer trace.Tracer
|
||||
svc calculator.Service
|
||||
}
|
||||
|
||||
func Tracing(svc calculator.Service, tracer trace.Tracer) calculator.Service {
|
||||
return &tracing{tracer, svc}
|
||||
}
|
||||
|
||||
func (t *tracing) Add(ctx context.Context, a, b int64) (result int64, err error) {
|
||||
defer t.trace(ctx, "calculator.Add", a, b, result, err)
|
||||
|
||||
return t.svc.Add(ctx, a, b)
|
||||
}
|
||||
|
||||
func (t *tracing) Subtract(ctx context.Context, a, b int64) (result int64, err error) {
|
||||
defer t.trace(ctx, "calculator.Subtract", a, b, result, err)
|
||||
|
||||
return t.svc.Subtract(ctx, a, b)
|
||||
}
|
||||
|
||||
func (t *tracing) Multiply(ctx context.Context, a, b int64) (result int64, err error) {
|
||||
defer t.trace(ctx, "calculator.Multiply", a, b, result, err)
|
||||
|
||||
return t.svc.Multiply(ctx, a, b)
|
||||
}
|
||||
|
||||
func (t *tracing) Divide(ctx context.Context, a, b int64) (result int64, err error) {
|
||||
defer t.trace(ctx, "calculator.Divide", a, b, result, err)
|
||||
|
||||
return t.svc.Divide(ctx, a, b)
|
||||
}
|
||||
|
||||
func (t *tracing) trace(ctx context.Context, name string, a, b, result int64, err error) {
|
||||
_, span := t.tracer.Start(ctx, name, trace.WithAttributes(
|
||||
attribute.Int64("a", a),
|
||||
attribute.Int64("b", b),
|
||||
attribute.Int64("result", result),
|
||||
attribute.String("error", err.Error()),
|
||||
))
|
||||
|
||||
span.End()
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package calculator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
maxMemory = 500 * 1024 * 1024 // 500 MB
|
||||
largeFactorialNumber = 3e5
|
||||
waitTime = 5 * time.Second
|
||||
)
|
||||
|
||||
type service struct {
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
func NewService(httpClient *http.Client) Service {
|
||||
return &service{
|
||||
httpClient: httpClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *service) Add(ctx context.Context, a, b int64) (int64, error) {
|
||||
largeSlice := make([]byte, maxMemory)
|
||||
|
||||
// This loop simulates holding onto memory without freeing it
|
||||
for i := range largeSlice {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
||||
return 0, ctx.Err()
|
||||
default:
|
||||
// Simulate work by filling the slice with data
|
||||
largeSlice[i] = byte(i)
|
||||
}
|
||||
}
|
||||
if err := errorFunc(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return a + b, nil
|
||||
}
|
||||
|
||||
func (s *service) Subtract(ctx context.Context, a, b int64) (int64, error) {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return 0, ctx.Err()
|
||||
default:
|
||||
time.Sleep(waitTime)
|
||||
}
|
||||
if err := errorFunc(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return a - b, nil
|
||||
}
|
||||
|
||||
func (s *service) Multiply(ctx context.Context, a, b int64) (int64, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, waitTime)
|
||||
defer cancel()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return 0, ctx.Err()
|
||||
default:
|
||||
if err := s.makePizzaRequest(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if err := errorFunc(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return a * b, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s *service) Divide(_ context.Context, a, b int64) (int64, error) {
|
||||
if err := errorFunc(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return int64(float64(a) / float64(b)), nil
|
||||
}
|
||||
|
||||
func (s *service) makePizzaRequest(ctx context.Context) error {
|
||||
const (
|
||||
thirdPartyURL = "https://quickpizza.grafana.com/api/pizza"
|
||||
maxCaloriesPerSlice = 1000
|
||||
maxBool = 2
|
||||
maxNumberOfToppings = 10
|
||||
minNumberOfToppings = 2
|
||||
)
|
||||
|
||||
payload := map[string]interface{}{
|
||||
"maxCaloriesPerSlice": generateRandomNumber(maxCaloriesPerSlice),
|
||||
"mustBeVegetarian": generateRandomNumber(maxBool) == 1,
|
||||
"excludedIngredients": []string{},
|
||||
"excludedTools": []string{},
|
||||
"maxNumberOfToppings": generateRandomNumber(maxNumberOfToppings),
|
||||
"minNumberOfToppings": generateRandomNumber(minNumberOfToppings),
|
||||
}
|
||||
data, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal payload: %w", err)
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, thirdPartyURL, bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "text/plain;charset=UTF-8")
|
||||
req.Header.Set("X-User-Id", "298337")
|
||||
|
||||
resp, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("request failed: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("request failed with status code %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read response body: %w", err)
|
||||
}
|
||||
|
||||
if len(body) == 0 {
|
||||
return errors.New("response body is empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func generateRandomNumber(maxNumber int64) int64 {
|
||||
n, err := rand.Int(rand.Reader, big.NewInt(maxNumber))
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return n.Int64()
|
||||
}
|
||||
|
||||
func errorFunc() error {
|
||||
if generateRandomNumber(10) > 7 { //nolint:gomnd,mnd // Using 7 as an arbitrary threshold for error generation
|
||||
return errors.New("random error")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
+100
-2
@@ -1,7 +1,105 @@
|
||||
package main
|
||||
|
||||
import "log"
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-retryablehttp"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/rodneyosodo/gophercon/calculator"
|
||||
"github.com/rodneyosodo/gophercon/calculator/api"
|
||||
"github.com/rodneyosodo/gophercon/calculator/middleware"
|
||||
"go.opentelemetry.io/otel/exporters/prometheus"
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
"google.golang.org/grpc/stats/opentelemetry"
|
||||
)
|
||||
|
||||
const defHTTPTimeout = 10 * time.Second
|
||||
|
||||
func main() {
|
||||
log.Println("Hello World")
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
var g *errgroup.Group
|
||||
g, _ = errgroup.WithContext(ctx)
|
||||
|
||||
logLevel := flag.String("log_level", "info", "log level")
|
||||
addr := flag.String("addr", ":11211", "gophercon calculator server address")
|
||||
prometheusEndpoint := flag.String("prometheus_endpoint", ":9464", "the Prometheus exporter endpoint")
|
||||
readTimeout := flag.Duration("read_timeout", defHTTPTimeout, "the read timeout for the server")
|
||||
writeTimeout := flag.Duration("write_timeout", defHTTPTimeout, "the write timeout for the server")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
var level slog.Level
|
||||
if err := level.UnmarshalText([]byte(*logLevel)); err != nil {
|
||||
log.Fatalf("failed to parse log level: %s", err.Error())
|
||||
}
|
||||
logHandler := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: level,
|
||||
})
|
||||
logger := slog.New(logHandler)
|
||||
slog.SetDefault(logger)
|
||||
|
||||
exporter, err := prometheus.New()
|
||||
if err != nil {
|
||||
logger.Error("Failed to start prometheus exporter", slog.String("error", err.Error()))
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
}
|
||||
provider := metric.NewMeterProvider(metric.WithReader(exporter))
|
||||
|
||||
g.Go(func() error {
|
||||
server := &http.Server{
|
||||
Addr: *prometheusEndpoint,
|
||||
Handler: promhttp.Handler(),
|
||||
ReadTimeout: *readTimeout,
|
||||
WriteTimeout: *writeTimeout,
|
||||
}
|
||||
|
||||
return server.ListenAndServe()
|
||||
})
|
||||
logger.Info("Prometheus exporter started", slog.String("endpoint", *prometheusEndpoint))
|
||||
|
||||
so := opentelemetry.ServerOption(
|
||||
opentelemetry.Options{MetricsOptions: opentelemetry.MetricsOptions{MeterProvider: provider}},
|
||||
)
|
||||
|
||||
listener, err := net.Listen("tcp", *addr)
|
||||
if err != nil {
|
||||
logger.Error("Failed to listen", slog.String("error", err.Error()))
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
server := grpc.NewServer(so)
|
||||
reflection.Register(server)
|
||||
|
||||
retryClient := retryablehttp.NewClient()
|
||||
retryClient.RetryMax = 10
|
||||
retryClient.Logger = logger
|
||||
httpClient := retryClient.StandardClient()
|
||||
|
||||
service := calculator.NewService(httpClient)
|
||||
service = middleware.Logging(logger, service)
|
||||
calculator.RegisterCalculatorServer(server, api.NewGrpcServer(service))
|
||||
|
||||
g.Go(func() error {
|
||||
return server.Serve(listener)
|
||||
})
|
||||
|
||||
logger.Info("Calculator server started", slog.String("address", *addr))
|
||||
|
||||
if err := g.Wait(); err != nil {
|
||||
logger.Error("Failed to serve", slog.String("error", err.Error()))
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,36 @@
|
||||
module github.com/rodneyosodo/gophercon
|
||||
|
||||
go 1.23.2
|
||||
|
||||
require (
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7
|
||||
github.com/prometheus/client_golang v1.20.5
|
||||
go.opentelemetry.io/otel v1.31.0
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.53.0
|
||||
go.opentelemetry.io/otel/sdk/metric v1.31.0
|
||||
go.opentelemetry.io/otel/trace v1.31.0
|
||||
golang.org/x/sync v0.8.0
|
||||
google.golang.org/grpc v1.67.1
|
||||
google.golang.org/grpc/stats/opentelemetry v0.0.0-20241016200935-ec10e73f02a3
|
||||
google.golang.org/protobuf v1.35.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.60.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.31.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
golang.org/x/text v0.19.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
|
||||
)
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
cel.dev/expr v0.16.1 h1:NR0+oFYzR1CqLFhTAqg3ql59G9VfN8fKq1TCHJ6gq1g=
|
||||
cel.dev/expr v0.16.1/go.mod h1:AsGA5zb3WruAEQeQng1RZdGEXmBj0jvMWh6l5SnNuC8=
|
||||
cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY=
|
||||
cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g=
|
||||
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78 h1:QVw89YDxXxEe+l8gU8ETbOasdwEV+avkR75ZzsVV9WI=
|
||||
github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/envoyproxy/go-control-plane v0.13.0 h1:HzkeUz1Knt+3bK+8LG1bxOO/jzWZmdxpwC51i202les=
|
||||
github.com/envoyproxy/go-control-plane v0.13.0/go.mod h1:GRaKG3dwvFoTg4nj7aXdZnvMg4d7nvT/wl9WgVXn3Q8=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.1.0 h1:tntQDh69XqOCOZsDz0lVJQez/2L6Uu2PdjCQwWCJ3bM=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.1.0/go.mod h1:sXRDRVmzEbkM7CVcM06s9shE/m23dg3wzjl0UWqJ2q4=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
|
||||
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo=
|
||||
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
|
||||
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA=
|
||||
github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
|
||||
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.53.0 h1:QXobPHrwiGLM4ufrY3EOmDPJpo2P90UuFau4CDPJA/I=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.53.0/go.mod h1:WOAXGr3D00CfzmFxtTV1eR0GpoHuPEu+HJT8UWW2SIU=
|
||||
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE=
|
||||
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY=
|
||||
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
|
||||
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8=
|
||||
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys=
|
||||
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
|
||||
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
|
||||
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
||||
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
|
||||
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
||||
google.golang.org/grpc/stats/opentelemetry v0.0.0-20241016195115-6cd00c93260b h1:ut5YTSkHaayJBGRoskBOfk8yam7lcf/u3PTHEDNXSQY=
|
||||
google.golang.org/grpc/stats/opentelemetry v0.0.0-20241016195115-6cd00c93260b/go.mod h1:xwT0YrcBcgR1ZSSLJtUgCjF5QlvTOhiwA/I9TcYf3Gg=
|
||||
google.golang.org/grpc/stats/opentelemetry v0.0.0-20241016200935-ec10e73f02a3 h1:SI+r2zromfd3aGS+7QTZ5a17ip8znCO8rHWv35iM+Nw=
|
||||
google.golang.org/grpc/stats/opentelemetry v0.0.0-20241016200935-ec10e73f02a3/go.mod h1:xwT0YrcBcgR1ZSSLJtUgCjF5QlvTOhiwA/I9TcYf3Gg=
|
||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
Reference in New Issue
Block a user