diff --git a/Makefile b/Makefile index 44e5ef9..3ca5a2e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ pwd := $(shell pwd) -all: cpp go doc +all: clean cpp go mockery doc .PHONY: cpp cpp: @@ -11,6 +11,11 @@ cpp: go: @echo "Generating apm-library package for Go" @docker run --user `id -u` --rm -v $(PWD):/defs namely/protoc-all:1.51_1 -d . -l go -o go + @docker run --rm -v "${PWD}":/apm-proto -w /apm-proto/go/collectorpb golang:1.21.0 sh -c "go mod init github.com/solarwinds/apm-proto/go/collectorpb && go mod tidy" + +.PHONY: mockery +mockery: + @docker run --user `id -u` --rm -v "${PWD}/go/collectorpb":/src -w /src vektra/mockery --all --case=underscore .PHONY: doc doc: diff --git a/go/collectorpb/go.mod b/go/collectorpb/go.mod new file mode 100644 index 0000000..808a87a --- /dev/null +++ b/go/collectorpb/go.mod @@ -0,0 +1,15 @@ +module github.com/solarwinds/apm-proto/go/collectorpb + +go 1.21.0 + +require ( + google.golang.org/grpc v1.64.0 + google.golang.org/protobuf v1.34.1 +) + +require ( + golang.org/x/net v0.22.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect +) diff --git a/go/collectorpb/go.sum b/go/collectorpb/go.sum new file mode 100644 index 0000000..d04c591 --- /dev/null +++ b/go/collectorpb/go.sum @@ -0,0 +1,14 @@ +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/go/collectorpb/mocks/trace_collector_client.go b/go/collectorpb/mocks/trace_collector_client.go new file mode 100644 index 0000000..17de60d --- /dev/null +++ b/go/collectorpb/mocks/trace_collector_client.go @@ -0,0 +1,217 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + context "context" + + collectorpb "github.com/solarwinds/apm-proto/go/collectorpb" + + grpc "google.golang.org/grpc" + + mock "github.com/stretchr/testify/mock" +) + +// TraceCollectorClient is an autogenerated mock type for the TraceCollectorClient type +type TraceCollectorClient struct { + mock.Mock +} + +// GetSettings provides a mock function with given fields: ctx, in, opts +func (_m *TraceCollectorClient) GetSettings(ctx context.Context, in *collectorpb.SettingsRequest, opts ...grpc.CallOption) (*collectorpb.SettingsResult, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetSettings") + } + + var r0 *collectorpb.SettingsResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.SettingsRequest, ...grpc.CallOption) (*collectorpb.SettingsResult, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.SettingsRequest, ...grpc.CallOption) *collectorpb.SettingsResult); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*collectorpb.SettingsResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *collectorpb.SettingsRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Ping provides a mock function with given fields: ctx, in, opts +func (_m *TraceCollectorClient) Ping(ctx context.Context, in *collectorpb.PingRequest, opts ...grpc.CallOption) (*collectorpb.MessageResult, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for Ping") + } + + var r0 *collectorpb.MessageResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.PingRequest, ...grpc.CallOption) (*collectorpb.MessageResult, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.PingRequest, ...grpc.CallOption) *collectorpb.MessageResult); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*collectorpb.MessageResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *collectorpb.PingRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// PostEvents provides a mock function with given fields: ctx, in, opts +func (_m *TraceCollectorClient) PostEvents(ctx context.Context, in *collectorpb.MessageRequest, opts ...grpc.CallOption) (*collectorpb.MessageResult, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for PostEvents") + } + + var r0 *collectorpb.MessageResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest, ...grpc.CallOption) (*collectorpb.MessageResult, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest, ...grpc.CallOption) *collectorpb.MessageResult); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*collectorpb.MessageResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *collectorpb.MessageRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// PostMetrics provides a mock function with given fields: ctx, in, opts +func (_m *TraceCollectorClient) PostMetrics(ctx context.Context, in *collectorpb.MessageRequest, opts ...grpc.CallOption) (*collectorpb.MessageResult, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for PostMetrics") + } + + var r0 *collectorpb.MessageResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest, ...grpc.CallOption) (*collectorpb.MessageResult, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest, ...grpc.CallOption) *collectorpb.MessageResult); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*collectorpb.MessageResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *collectorpb.MessageRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// PostStatus provides a mock function with given fields: ctx, in, opts +func (_m *TraceCollectorClient) PostStatus(ctx context.Context, in *collectorpb.MessageRequest, opts ...grpc.CallOption) (*collectorpb.MessageResult, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for PostStatus") + } + + var r0 *collectorpb.MessageResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest, ...grpc.CallOption) (*collectorpb.MessageResult, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest, ...grpc.CallOption) *collectorpb.MessageResult); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*collectorpb.MessageResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *collectorpb.MessageRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewTraceCollectorClient creates a new instance of TraceCollectorClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewTraceCollectorClient(t interface { + mock.TestingT + Cleanup(func()) +}) *TraceCollectorClient { + mock := &TraceCollectorClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/go/collectorpb/mocks/trace_collector_server.go b/go/collectorpb/mocks/trace_collector_server.go new file mode 100644 index 0000000..d650a6c --- /dev/null +++ b/go/collectorpb/mocks/trace_collector_server.go @@ -0,0 +1,180 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + context "context" + + collectorpb "github.com/solarwinds/apm-proto/go/collectorpb" + + mock "github.com/stretchr/testify/mock" +) + +// TraceCollectorServer is an autogenerated mock type for the TraceCollectorServer type +type TraceCollectorServer struct { + mock.Mock +} + +// GetSettings provides a mock function with given fields: _a0, _a1 +func (_m *TraceCollectorServer) GetSettings(_a0 context.Context, _a1 *collectorpb.SettingsRequest) (*collectorpb.SettingsResult, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for GetSettings") + } + + var r0 *collectorpb.SettingsResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.SettingsRequest) (*collectorpb.SettingsResult, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.SettingsRequest) *collectorpb.SettingsResult); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*collectorpb.SettingsResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *collectorpb.SettingsRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Ping provides a mock function with given fields: _a0, _a1 +func (_m *TraceCollectorServer) Ping(_a0 context.Context, _a1 *collectorpb.PingRequest) (*collectorpb.MessageResult, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for Ping") + } + + var r0 *collectorpb.MessageResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.PingRequest) (*collectorpb.MessageResult, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.PingRequest) *collectorpb.MessageResult); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*collectorpb.MessageResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *collectorpb.PingRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// PostEvents provides a mock function with given fields: _a0, _a1 +func (_m *TraceCollectorServer) PostEvents(_a0 context.Context, _a1 *collectorpb.MessageRequest) (*collectorpb.MessageResult, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for PostEvents") + } + + var r0 *collectorpb.MessageResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest) (*collectorpb.MessageResult, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest) *collectorpb.MessageResult); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*collectorpb.MessageResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *collectorpb.MessageRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// PostMetrics provides a mock function with given fields: _a0, _a1 +func (_m *TraceCollectorServer) PostMetrics(_a0 context.Context, _a1 *collectorpb.MessageRequest) (*collectorpb.MessageResult, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for PostMetrics") + } + + var r0 *collectorpb.MessageResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest) (*collectorpb.MessageResult, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest) *collectorpb.MessageResult); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*collectorpb.MessageResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *collectorpb.MessageRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// PostStatus provides a mock function with given fields: _a0, _a1 +func (_m *TraceCollectorServer) PostStatus(_a0 context.Context, _a1 *collectorpb.MessageRequest) (*collectorpb.MessageResult, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for PostStatus") + } + + var r0 *collectorpb.MessageResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest) (*collectorpb.MessageResult, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, *collectorpb.MessageRequest) *collectorpb.MessageResult); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*collectorpb.MessageResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *collectorpb.MessageRequest) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewTraceCollectorServer creates a new instance of TraceCollectorServer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewTraceCollectorServer(t interface { + mock.TestingT + Cleanup(func()) +}) *TraceCollectorServer { + mock := &TraceCollectorServer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/go/collectorpb/mocks/unsafe_trace_collector_server.go b/go/collectorpb/mocks/unsafe_trace_collector_server.go new file mode 100644 index 0000000..0c87884 --- /dev/null +++ b/go/collectorpb/mocks/unsafe_trace_collector_server.go @@ -0,0 +1,29 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// UnsafeTraceCollectorServer is an autogenerated mock type for the UnsafeTraceCollectorServer type +type UnsafeTraceCollectorServer struct { + mock.Mock +} + +// mustEmbedUnimplementedTraceCollectorServer provides a mock function with given fields: +func (_m *UnsafeTraceCollectorServer) mustEmbedUnimplementedTraceCollectorServer() { + _m.Called() +} + +// NewUnsafeTraceCollectorServer creates a new instance of UnsafeTraceCollectorServer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUnsafeTraceCollectorServer(t interface { + mock.TestingT + Cleanup(func()) +}) *UnsafeTraceCollectorServer { + mock := &UnsafeTraceCollectorServer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}