move to micro v4 #119

Merged
vtolstov merged 1 commits from v4 into master 2023-05-07 19:19:28 +03:00
9 changed files with 59 additions and 1027 deletions
Showing only changes of commit 5ce0755cae - Show all commits

View File

@ -1,3 +1,3 @@
package service package service
//go:generate protoc -I./proto -I. --go-grpc_out=paths=source_relative:./proto --go_out=paths=source_relative:./proto --go-micro_out=components=micro|rpc,standalone=true,debug=true,paths=source_relative:./micro proto/service.proto //go:generate protoc -I./proto -I. --go_out=paths=source_relative:./proto --go-micro_out=components=micro|rpc,standalone=true,debug=true,paths=source_relative:./micro proto/service.proto

19
go.mod
View File

@ -1,10 +1,21 @@
module go.unistack.org/micro-logger-service/v3 module go.unistack.org/micro-logger-service/v4
go 1.16 go 1.20
require ( require (
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
go.unistack.org/micro/v3 v3.10.11 go.unistack.org/micro-logger-service/v3 v3.8.1
google.golang.org/grpc v1.52.3 go.unistack.org/micro-server-http/v4 v4.0.1
go.unistack.org/micro/v4 v4.0.1
google.golang.org/protobuf v1.28.1 google.golang.org/protobuf v1.28.1
) )
require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
google.golang.org/grpc v1.52.3 // indirect
)

913
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT. // Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.5.3 // versions:
// - protoc-gen-go-micro v4.0.0
// - protoc v3.21.12
// source: service.proto // source: service.proto
package servicepb package servicepb
@ -7,19 +9,16 @@ package servicepb
import ( import (
context "context" context "context"
proto "go.unistack.org/micro-logger-service/v3/proto" proto "go.unistack.org/micro-logger-service/v3/proto"
api "go.unistack.org/micro/v3/api" v4 "go.unistack.org/micro-server-http/v4"
client "go.unistack.org/micro/v3/client" client "go.unistack.org/micro/v4/client"
) )
var ( var (
LoggerServiceName = "LoggerService" LoggerServiceName = "LoggerService"
LoggerServiceEndpoints = []api.Endpoint{}
) )
var (
func NewLoggerServiceEndpoints() []api.Endpoint { LoggerServiceServerEndpoints = []v4.EndpointMetadata{}
return LoggerServiceEndpoints )
}
type LoggerServiceClient interface { type LoggerServiceClient interface {
Log(ctx context.Context, req *proto.LogReq, opts ...client.CallOption) (*proto.LogRsp, error) Log(ctx context.Context, req *proto.LogReq, opts ...client.CallOption) (*proto.LogRsp, error)

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT. // Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.5.3 // protoc-gen-go-micro version: v4.0.0
// source: service.proto // source: service.proto
package servicepb package servicepb
@ -7,9 +7,8 @@ package servicepb
import ( import (
context "context" context "context"
proto "go.unistack.org/micro-logger-service/v3/proto" proto "go.unistack.org/micro-logger-service/v3/proto"
api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v4/client"
client "go.unistack.org/micro/v3/client" server "go.unistack.org/micro/v4/server"
server "go.unistack.org/micro/v3/server"
) )
type loggerServiceClient struct { type loggerServiceClient struct {
@ -47,8 +46,5 @@ func RegisterLoggerServiceServer(s server.Server, sh LoggerServiceServer, opts .
} }
h := &loggerServiceServer{sh} h := &loggerServiceServer{sh}
var nopts []server.HandlerOption var nopts []server.HandlerOption
for _, endpoint := range LoggerServiceEndpoints {
nopts = append(nopts, api.WithEndpoint(&endpoint))
}
return s.Handle(s.NewHandler(&LoggerService{h}, append(nopts, opts...)...)) return s.Handle(s.NewHandler(&LoggerService{h}, append(nopts, opts...)...))
} }

View File

@ -1,9 +1,9 @@
package service package service
import ( import (
"go.unistack.org/micro/v3/client" "go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v3/logger" "go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v3/store" "go.unistack.org/micro/v4/store"
) )
type clientKey struct{} type clientKey struct{}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.26.0 // protoc-gen-go v1.26.0
// protoc v3.19.4 // protoc v3.21.12
// source: service.proto // source: service.proto
package servicepb package servicepb

View File

@ -1,105 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.19.4
// source: service.proto
package servicepb
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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// LoggerServiceClient is the client API for LoggerService 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.
type LoggerServiceClient interface {
Log(ctx context.Context, in *LogReq, opts ...grpc.CallOption) (*LogRsp, error)
}
type loggerServiceClient struct {
cc grpc.ClientConnInterface
}
func NewLoggerServiceClient(cc grpc.ClientConnInterface) LoggerServiceClient {
return &loggerServiceClient{cc}
}
func (c *loggerServiceClient) Log(ctx context.Context, in *LogReq, opts ...grpc.CallOption) (*LogRsp, error) {
out := new(LogRsp)
err := c.cc.Invoke(ctx, "/servicepb.LoggerService/Log", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// LoggerServiceServer is the server API for LoggerService service.
// All implementations must embed UnimplementedLoggerServiceServer
// for forward compatibility
type LoggerServiceServer interface {
Log(context.Context, *LogReq) (*LogRsp, error)
mustEmbedUnimplementedLoggerServiceServer()
}
// UnimplementedLoggerServiceServer must be embedded to have forward compatible implementations.
type UnimplementedLoggerServiceServer struct {
}
func (UnimplementedLoggerServiceServer) Log(context.Context, *LogReq) (*LogRsp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Log not implemented")
}
func (UnimplementedLoggerServiceServer) mustEmbedUnimplementedLoggerServiceServer() {}
// UnsafeLoggerServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to LoggerServiceServer will
// result in compilation errors.
type UnsafeLoggerServiceServer interface {
mustEmbedUnimplementedLoggerServiceServer()
}
func RegisterLoggerServiceServer(s grpc.ServiceRegistrar, srv LoggerServiceServer) {
s.RegisterService(&LoggerService_ServiceDesc, srv)
}
func _LoggerService_Log_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LogReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LoggerServiceServer).Log(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/servicepb.LoggerService/Log",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LoggerServiceServer).Log(ctx, req.(*LogReq))
}
return interceptor(ctx, in, info, handler)
}
// LoggerService_ServiceDesc is the grpc.ServiceDesc for LoggerService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var LoggerService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "servicepb.LoggerService",
HandlerType: (*LoggerServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Log",
Handler: _LoggerService_Log_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service.proto",
}

View File

@ -1,4 +1,4 @@
package service // import "go.unistack.org/micro-logger-service/v3" package service // import "go.unistack.org/micro-logger-service/v4"
import ( import (
"context" "context"
@ -6,11 +6,11 @@ import (
"os" "os"
"github.com/google/uuid" "github.com/google/uuid"
pbmicro "go.unistack.org/micro-logger-service/v3/micro" pbmicro "go.unistack.org/micro-logger-service/v4/micro"
pb "go.unistack.org/micro-logger-service/v3/proto" pb "go.unistack.org/micro-logger-service/v4/proto"
"go.unistack.org/micro/v3/client" "go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v3/logger" "go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v3/store" "go.unistack.org/micro/v4/store"
) )
var _ logger.Logger = &serviceLogger{} var _ logger.Logger = &serviceLogger{}