move to micro v4
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
fad3693ddc
commit
5ce0755cae
@ -1,3 +1,3 @@
|
||||
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
19
go.mod
@ -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 (
|
||||
github.com/google/uuid v1.3.0
|
||||
go.unistack.org/micro/v3 v3.10.11
|
||||
google.golang.org/grpc v1.52.3
|
||||
go.unistack.org/micro-logger-service/v3 v3.8.1
|
||||
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
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
|
@ -1,5 +1,7 @@
|
||||
// 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
|
||||
|
||||
package servicepb
|
||||
@ -7,19 +9,16 @@ package servicepb
|
||||
import (
|
||||
context "context"
|
||||
proto "go.unistack.org/micro-logger-service/v3/proto"
|
||||
api "go.unistack.org/micro/v3/api"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
v4 "go.unistack.org/micro-server-http/v4"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var (
|
||||
LoggerServiceName = "LoggerService"
|
||||
|
||||
LoggerServiceEndpoints = []api.Endpoint{}
|
||||
)
|
||||
|
||||
func NewLoggerServiceEndpoints() []api.Endpoint {
|
||||
return LoggerServiceEndpoints
|
||||
}
|
||||
var (
|
||||
LoggerServiceServerEndpoints = []v4.EndpointMetadata{}
|
||||
)
|
||||
|
||||
type LoggerServiceClient interface {
|
||||
Log(ctx context.Context, req *proto.LogReq, opts ...client.CallOption) (*proto.LogRsp, error)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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
|
||||
|
||||
package servicepb
|
||||
@ -7,9 +7,8 @@ package servicepb
|
||||
import (
|
||||
context "context"
|
||||
proto "go.unistack.org/micro-logger-service/v3/proto"
|
||||
api "go.unistack.org/micro/v3/api"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type loggerServiceClient struct {
|
||||
@ -47,8 +46,5 @@ func RegisterLoggerServiceServer(s server.Server, sh LoggerServiceServer, opts .
|
||||
}
|
||||
h := &loggerServiceServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
for _, endpoint := range LoggerServiceEndpoints {
|
||||
nopts = append(nopts, api.WithEndpoint(&endpoint))
|
||||
}
|
||||
return s.Handle(s.NewHandler(&LoggerService{h}, append(nopts, opts...)...))
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/store"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/micro/v4/store"
|
||||
)
|
||||
|
||||
type clientKey struct{}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v3.19.4
|
||||
// protoc v3.21.12
|
||||
// source: service.proto
|
||||
|
||||
package servicepb
|
||||
|
@ -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",
|
||||
}
|
12
service.go
12
service.go
@ -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 (
|
||||
"context"
|
||||
@ -6,11 +6,11 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/google/uuid"
|
||||
pbmicro "go.unistack.org/micro-logger-service/v3/micro"
|
||||
pb "go.unistack.org/micro-logger-service/v3/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/store"
|
||||
pbmicro "go.unistack.org/micro-logger-service/v4/micro"
|
||||
pb "go.unistack.org/micro-logger-service/v4/proto"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/micro/v4/store"
|
||||
)
|
||||
|
||||
var _ logger.Logger = &serviceLogger{}
|
||||
|
Loading…
Reference in New Issue
Block a user