Skip to content
Snippets Groups Projects
Commit be687718 authored by Pavel Antonov's avatar Pavel Antonov :asterisk:
Browse files

Merge branch 'feature/PRXS-1449-ReferencePublish' into 'master'

Добавлен метод Publish в сервисе reference, сгенерированы клиенты из обновленных proto файлов

See merge request perxis/perxis-go!80
parents ee80770d 1a76633c
No related branches found
No related tags found
No related merge requests found
Showing
with 632 additions and 84 deletions
......@@ -88,3 +88,12 @@ mocks: $(MOCKS)
mocks-clean:
@rm -rf $(MOCKS)
# Deprecated
# Генерация кода для go-kit при помощи 'github.com/devimteam/microgen' - go-kit перешел на github.com/recolabs/microgen/cmd/microgen
#MICROGENFILES?=$(shell find . -name "service.go" -exec grep -Ril "microgen" {} \;)
#microgen: $(MICROGENFILES)
#
#%/service.go: % .FORCE
# -microgen -file "$@" -out "$<"
Subproject commit f000812a1eef24093c0d0abf1318e3179b679773
Subproject commit 062d090c3a8e44d3cc4ca61678bf58c0e7377812
......@@ -40,3 +40,7 @@ func (m *encodeDecodeMiddleware) Get(ctx context.Context, spaceId, envId string,
}
return
}
func (m *encodeDecodeMiddleware) Publish(ctx context.Context, spaceId string, envId string, references []*references.Reference, recursive bool, force bool) (published []*references.Reference, notfound []*references.Reference, unpublished []*references.Reference, err error) {
return m.next.Publish(ctx, spaceId, envId, references, recursive, force)
}
package middleware
// Code generated by gowrap. DO NOT EDIT.
// template: ../../../assets/templates/middleware/error_log
// gowrap: http://github.com/hexdigest/gowrap
// DO NOT EDIT!
// This code is generated with http://github.com/hexdigest/gowrap tool
// using ../../../assets/templates/middleware/error_log template
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/error_log -o error_logging_middleware.go -l ""
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/error_log -o error_logging_middleware.go
import (
"context"
......@@ -39,3 +39,13 @@ func (m *errorLoggingMiddleware) Get(ctx context.Context, spaceId string, envId
}()
return m.next.Get(ctx, spaceId, envId, references)
}
func (m *errorLoggingMiddleware) Publish(ctx context.Context, spaceId string, envId string, references []*references.Reference, recursive bool, force bool) (published []*references.Reference, notfound []*references.Reference, unpublished []*references.Reference, err error) {
logger := m.logger
defer func() {
if err != nil {
logger.Warn("response error", zap.Error(err))
}
}()
return m.next.Publish(ctx, spaceId, envId, references, recursive, force)
}
package middleware
// Code generated by gowrap. DO NOT EDIT.
// template: ../../../assets/templates/middleware/access_log
// gowrap: http://github.com/hexdigest/gowrap
// DO NOT EDIT!
// This code is generated with http://github.com/hexdigest/gowrap tool
// using ../../../assets/templates/middleware/access_log template
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/access_log -o logging_middleware.go -l ""
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/access_log -o logging_middleware.go
import (
"context"
......@@ -73,3 +73,46 @@ func (m *loggingMiddleware) Get(ctx context.Context, spaceId string, envId strin
return items, notfound, err
}
func (m *loggingMiddleware) Publish(ctx context.Context, spaceId string, envId string, references []*references.Reference, recursive bool, force bool) (published []*references.Reference, notfound []*references.Reference, unpublished []*references.Reference, err error) {
begin := time.Now()
var fields []zapcore.Field
for k, v := range map[string]interface{}{
"ctx": ctx,
"spaceId": spaceId,
"envId": envId,
"references": references,
"recursive": recursive,
"force": force} {
if k == "ctx" {
fields = append(fields, zap.String("principal", fmt.Sprint(auth.GetPrincipal(ctx))))
continue
}
fields = append(fields, zap.Reflect(k, v))
}
m.logger.Debug("Publish.Request", fields...)
published, notfound, unpublished, err = m.next.Publish(ctx, spaceId, envId, references, recursive, force)
fields = []zapcore.Field{
zap.Duration("time", time.Since(begin)),
}
for k, v := range map[string]interface{}{
"published": published,
"notfound": notfound,
"unpublished": unpublished,
"err": err} {
if k == "err" {
err, _ := v.(error)
fields = append(fields, zap.Error(err))
continue
}
fields = append(fields, zap.Reflect(k, v))
}
m.logger.Debug("Publish.Response", fields...)
return published, notfound, unpublished, err
}
// Code generated by gowrap. DO NOT EDIT.
// template: ../../../assets/templates/middleware/middleware
// gowrap: http://github.com/hexdigest/gowrap
package middleware
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/middleware -o middleware.go -l ""
// DO NOT EDIT!
// This code is generated with http://github.com/hexdigest/gowrap tool
// using ../../../assets/templates/middleware/middleware template
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/middleware -o middleware.go
import (
"git.perx.ru/perxis/perxis-go/pkg/references"
......
// Code generated by gowrap. DO NOT EDIT.
// template: ../../../assets/templates/middleware/recovery
// gowrap: http://github.com/hexdigest/gowrap
package middleware
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/recovery -o recovering_middleware.go -l ""
// DO NOT EDIT!
// This code is generated with http://github.com/hexdigest/gowrap tool
// using ../../../assets/templates/middleware/recovery template
//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/recovery -o recovering_middleware.go
import (
"context"
......@@ -42,3 +42,15 @@ func (m *recoveringMiddleware) Get(ctx context.Context, spaceId string, envId st
return m.next.Get(ctx, spaceId, envId, references)
}
func (m *recoveringMiddleware) Publish(ctx context.Context, spaceId string, envId string, references []*references.Reference, recursive bool, force bool) (published []*references.Reference, notfound []*references.Reference, unpublished []*references.Reference, err error) {
logger := m.logger
defer func() {
if r := recover(); r != nil {
logger.Error("panic", zap.Error(fmt.Errorf("%v", r)))
err = fmt.Errorf("%v", r)
}
}()
return m.next.Publish(ctx, spaceId, envId, references, recursive, force)
}
// Code generated by mockery v2.15.0. DO NOT EDIT.
// Code generated by mockery v2.22.1. DO NOT EDIT.
package mocks
......
// Code generated by mockery v2.15.0. DO NOT EDIT.
// Code generated by mockery v2.22.1. DO NOT EDIT.
package mocks
......@@ -21,6 +21,11 @@ func (_m *References) Get(ctx context.Context, spaceId string, envId string, _a3
ret := _m.Called(ctx, spaceId, envId, _a3)
var r0 []*items.Item
var r1 []*references.Reference
var r2 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, []*references.Reference) ([]*items.Item, []*references.Reference, error)); ok {
return rf(ctx, spaceId, envId, _a3)
}
if rf, ok := ret.Get(0).(func(context.Context, string, string, []*references.Reference) []*items.Item); ok {
r0 = rf(ctx, spaceId, envId, _a3)
} else {
......@@ -29,7 +34,6 @@ func (_m *References) Get(ctx context.Context, spaceId string, envId string, _a3
}
}
var r1 []*references.Reference
if rf, ok := ret.Get(1).(func(context.Context, string, string, []*references.Reference) []*references.Reference); ok {
r1 = rf(ctx, spaceId, envId, _a3)
} else {
......@@ -38,7 +42,6 @@ func (_m *References) Get(ctx context.Context, spaceId string, envId string, _a3
}
}
var r2 error
if rf, ok := ret.Get(2).(func(context.Context, string, string, []*references.Reference) error); ok {
r2 = rf(ctx, spaceId, envId, _a3)
} else {
......@@ -48,6 +51,50 @@ func (_m *References) Get(ctx context.Context, spaceId string, envId string, _a3
return r0, r1, r2
}
// Publish provides a mock function with given fields: ctx, spaceId, envId, _a3, recursive, force
func (_m *References) Publish(ctx context.Context, spaceId string, envId string, _a3 []*references.Reference, recursive bool, force bool) ([]*references.Reference, []*references.Reference, []*references.Reference, error) {
ret := _m.Called(ctx, spaceId, envId, _a3, recursive, force)
var r0 []*references.Reference
var r1 []*references.Reference
var r2 []*references.Reference
var r3 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, []*references.Reference, bool, bool) ([]*references.Reference, []*references.Reference, []*references.Reference, error)); ok {
return rf(ctx, spaceId, envId, _a3, recursive, force)
}
if rf, ok := ret.Get(0).(func(context.Context, string, string, []*references.Reference, bool, bool) []*references.Reference); ok {
r0 = rf(ctx, spaceId, envId, _a3, recursive, force)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*references.Reference)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, string, []*references.Reference, bool, bool) []*references.Reference); ok {
r1 = rf(ctx, spaceId, envId, _a3, recursive, force)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).([]*references.Reference)
}
}
if rf, ok := ret.Get(2).(func(context.Context, string, string, []*references.Reference, bool, bool) []*references.Reference); ok {
r2 = rf(ctx, spaceId, envId, _a3, recursive, force)
} else {
if ret.Get(2) != nil {
r2 = ret.Get(2).([]*references.Reference)
}
}
if rf, ok := ret.Get(3).(func(context.Context, string, string, []*references.Reference, bool, bool) error); ok {
r3 = rf(ctx, spaceId, envId, _a3, recursive, force)
} else {
r3 = ret.Error(3)
}
return r0, r1, r2, r3
}
type mockConstructorTestingTNewReferences interface {
mock.TestingT
Cleanup(func())
......
......@@ -11,4 +11,6 @@ import (
// @grpc-addr content.references.References
type References interface {
Get(ctx context.Context, spaceId, envId string, references []*Reference) (items []*items.Item, notfound []*Reference, err error)
Publish(ctx context.Context, spaceId, envId string, references []*Reference, recursive, force bool) (published []*Reference, notfound []*Reference, unpublished []*Reference, err error)
}
// Code generated by microgen 0.9.1. DO NOT EDIT.
// Code generated by microgen 1.0.4. DO NOT EDIT.
package transport
......@@ -27,3 +27,21 @@ func (set EndpointsSet) Get(arg0 context.Context, arg1 string, arg2 string, arg3
}
return response.(*GetResponse).Items, response.(*GetResponse).Notfound, res2
}
func (set EndpointsSet) Publish(arg0 context.Context, arg1 string, arg2 string, arg3 []*references.Reference, arg4 bool, arg5 bool) (res0 []*references.Reference, res1 []*references.Reference, res2 []*references.Reference, res3 error) {
request := PublishRequest{
EnvId: arg2,
Force: arg5,
Recursive: arg4,
References: arg3,
SpaceId: arg1,
}
response, res3 := set.PublishEndpoint(arg0, &request)
if res3 != nil {
if e, ok := status.FromError(res3); ok || e.Code() == codes.Internal || e.Code() == codes.Unknown {
res3 = errors.New(e.Message())
}
return
}
return response.(*PublishResponse).Published, response.(*PublishResponse).Notfound, response.(*PublishResponse).Unpublished, res3
}
// Code generated by microgen 0.9.1. DO NOT EDIT.
// Code generated by microgen 1.0.4. DO NOT EDIT.
package transport
......@@ -7,4 +7,5 @@ import endpoint "github.com/go-kit/kit/endpoint"
// EndpointsSet implements References API and used for transport purposes.
type EndpointsSet struct {
GetEndpoint endpoint.Endpoint
PublishEndpoint endpoint.Endpoint
}
// Code generated by microgen 0.9.1. DO NOT EDIT.
// Code generated by microgen 1.0.4. DO NOT EDIT.
package transport
import (
items "git.perx.ru/perxis/perxis-go/pkg/items"
references "git.perx.ru/perxis/perxis-go/pkg/references"
"git.perx.ru/perxis/perxis-go/pkg/items"
"git.perx.ru/perxis/perxis-go/pkg/references"
)
type (
......@@ -17,4 +17,17 @@ type (
Items []*items.Item `json:"items"`
Notfound []*references.Reference `json:"notfound"`
}
PublishRequest struct {
SpaceId string `json:"space_id"`
EnvId string `json:"env_id"`
References []*references.Reference `json:"references"`
Recursive bool `json:"recursive"`
Force bool `json:"force"`
}
PublishResponse struct {
Published []*references.Reference `json:"published"`
Notfound []*references.Reference `json:"notfound"`
Unpublished []*references.Reference `json:"unpublished"`
}
)
// Code generated by microgen 0.9.1. DO NOT EDIT.
// Code generated by microgen 1.0.4. DO NOT EDIT.
package transportgrpc
import (
transport "git.perx.ru/perxis/perxis-go/pkg/references/transport"
"git.perx.ru/perxis/perxis-go/pkg/references/transport"
pb "git.perx.ru/perxis/perxis-go/proto/references"
grpckit "github.com/go-kit/kit/transport/grpc"
grpc "google.golang.org/grpc"
......@@ -13,11 +13,20 @@ func NewGRPCClient(conn *grpc.ClientConn, addr string, opts ...grpckit.ClientOpt
if addr == "" {
addr = "content.references.References"
}
return transport.EndpointsSet{GetEndpoint: grpckit.NewClient(
return transport.EndpointsSet{
GetEndpoint: grpckit.NewClient(
conn, addr, "Get",
_Encode_Get_Request,
_Decode_Get_Response,
pb.GetResponse{},
opts...,
).Endpoint()}
).Endpoint(),
PublishEndpoint: grpckit.NewClient(
conn, addr, "Publish",
_Encode_Publish_Request,
_Decode_Publish_Response,
pb.PublishResponse{},
opts...,
).Endpoint(),
}
}
// Code generated by microgen 0.9.1. DO NOT EDIT.
// Code generated by microgen 1.0.4. DO NOT EDIT.
// Please, do not change functions names!
package transportgrpc
......@@ -7,7 +7,7 @@ import (
"context"
"errors"
transport "git.perx.ru/perxis/perxis-go/pkg/references/transport"
"git.perx.ru/perxis/perxis-go/pkg/references/transport"
pb "git.perx.ru/perxis/perxis-go/proto/references"
)
......@@ -80,3 +80,87 @@ func _Decode_Get_Response(ctx context.Context, response interface{}) (interface{
Notfound: respNotfound,
}, nil
}
func _Encode_Publish_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil PublishRequest")
}
req := request.(*transport.PublishRequest)
reqReferences, err := ListPtrReferenceToProto(req.References)
if err != nil {
return nil, err
}
return &pb.PublishRequest{
EnvId: req.EnvId,
Force: req.Force,
Recursive: req.Recursive,
References: reqReferences,
SpaceId: req.SpaceId,
}, nil
}
func _Encode_Publish_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil PublishResponse")
}
resp := response.(*transport.PublishResponse)
respPublished, err := ListPtrReferenceToProto(resp.Published)
if err != nil {
return nil, err
}
respNotfound, err := ListPtrReferenceToProto(resp.Notfound)
if err != nil {
return nil, err
}
respUnpublished, err := ListPtrReferenceToProto(resp.Unpublished)
if err != nil {
return nil, err
}
return &pb.PublishResponse{
Notfound: respNotfound,
Published: respPublished,
Unpublished: respUnpublished,
}, nil
}
func _Decode_Publish_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil PublishRequest")
}
req := request.(*pb.PublishRequest)
reqReferences, err := ProtoToListPtrReference(req.References)
if err != nil {
return nil, err
}
return &transport.PublishRequest{
EnvId: string(req.EnvId),
Force: bool(req.Force),
Recursive: bool(req.Recursive),
References: reqReferences,
SpaceId: string(req.SpaceId),
}, nil
}
func _Decode_Publish_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil PublishResponse")
}
resp := response.(*pb.PublishResponse)
respPublished, err := ProtoToListPtrReference(resp.Published)
if err != nil {
return nil, err
}
respNotfound, err := ProtoToListPtrReference(resp.Notfound)
if err != nil {
return nil, err
}
respUnpublished, err := ProtoToListPtrReference(resp.Unpublished)
if err != nil {
return nil, err
}
return &transport.PublishResponse{
Notfound: respNotfound,
Published: respPublished,
Unpublished: respUnpublished,
}, nil
}
// Code generated by microgen 0.9.1. DO NOT EDIT.
// Code generated by microgen 1.0.4. DO NOT EDIT.
// DO NOT EDIT.
package transportgrpc
import (
transport "git.perx.ru/perxis/perxis-go/pkg/references/transport"
"git.perx.ru/perxis/perxis-go/pkg/references/transport"
pb "git.perx.ru/perxis/perxis-go/proto/references"
grpc "github.com/go-kit/kit/transport/grpc"
context "golang.org/x/net/context"
"github.com/go-kit/kit/transport/grpc"
"golang.org/x/net/context"
)
type referencesServer struct {
get grpc.Handler
publish grpc.Handler
pb.UnsafeReferencesServer
}
func NewGRPCServer(endpoints *transport.EndpointsSet, opts ...grpc.ServerOption) pb.ReferencesServer {
return &referencesServer{get: grpc.NewServer(
return &referencesServer{
get: grpc.NewServer(
endpoints.GetEndpoint,
_Decode_Get_Request,
_Encode_Get_Response,
opts...,
)}
),
publish: grpc.NewServer(
endpoints.PublishEndpoint,
_Decode_Publish_Request,
_Encode_Publish_Response,
opts...,
),
}
}
func (S *referencesServer) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse, error) {
......@@ -32,3 +41,11 @@ func (S *referencesServer) Get(ctx context.Context, req *pb.GetRequest) (*pb.Get
}
return resp.(*pb.GetResponse), nil
}
func (S *referencesServer) Publish(ctx context.Context, req *pb.PublishRequest) (*pb.PublishResponse, error) {
_, resp, err := S.publish.ServeGRPC(ctx, req)
if err != nil {
return nil, err
}
return resp.(*pb.PublishResponse), nil
}
// Code generated by microgen 0.9.1. DO NOT EDIT.
// Code generated by microgen 1.0.4. DO NOT EDIT.
package transport
import (
"context"
references "git.perx.ru/perxis/perxis-go/pkg/references"
endpoint "github.com/go-kit/kit/endpoint"
"git.perx.ru/perxis/perxis-go/pkg/references"
"github.com/go-kit/kit/endpoint"
)
func Endpoints(svc references.References) EndpointsSet {
return EndpointsSet{GetEndpoint: GetEndpoint(svc)}
return EndpointsSet{
GetEndpoint: GetEndpoint(svc),
PublishEndpoint: PublishEndpoint(svc),
}
}
func GetEndpoint(svc references.References) endpoint.Endpoint {
......@@ -23,3 +26,15 @@ func GetEndpoint(svc references.References) endpoint.Endpoint {
}, res2
}
}
func PublishEndpoint(svc references.References) endpoint.Endpoint {
return func(arg0 context.Context, request interface{}) (interface{}, error) {
req := request.(*PublishRequest)
res0, res1, res2, res3 := svc.Publish(arg0, req.SpaceId, req.EnvId, req.References, req.Recursive, req.Force)
return &PublishResponse{
Notfound: res1,
Published: res0,
Unpublished: res2,
}, res3
}
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.29.0
// protoc v3.21.12
// protoc-gen-go v1.31.0
// protoc v4.23.4
// source: references/references.proto
package references
......@@ -202,6 +202,150 @@ func (x *GetResponse) GetNotfound() []*Reference {
return nil
}
// PublishRequest запрос на публикацию записей по ссылкам
type PublishRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
SpaceId string `protobuf:"bytes,1,opt,name=space_id,json=spaceId,proto3" json:"space_id,omitempty"` // Пространство публикации
EnvId string `protobuf:"bytes,2,opt,name=env_id,json=envId,proto3" json:"env_id,omitempty"` // Окружение публикации
References []*Reference `protobuf:"bytes,3,rep,name=references,proto3" json:"references,omitempty"` // Список ссылок на записи для публикации
Recursive bool `protobuf:"varint,4,opt,name=recursive,proto3" json:"recursive,omitempty"` // Рекурсивно публиковать все ссылки на найденные записи
Force bool `protobuf:"varint,5,opt,name=force,proto3" json:"force,omitempty"` // Принудительно публиковать записи, даже если они содержат не опубликованные ссылки
}
func (x *PublishRequest) Reset() {
*x = PublishRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_references_references_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PublishRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PublishRequest) ProtoMessage() {}
func (x *PublishRequest) ProtoReflect() protoreflect.Message {
mi := &file_references_references_proto_msgTypes[3]
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 PublishRequest.ProtoReflect.Descriptor instead.
func (*PublishRequest) Descriptor() ([]byte, []int) {
return file_references_references_proto_rawDescGZIP(), []int{3}
}
func (x *PublishRequest) GetSpaceId() string {
if x != nil {
return x.SpaceId
}
return ""
}
func (x *PublishRequest) GetEnvId() string {
if x != nil {
return x.EnvId
}
return ""
}
func (x *PublishRequest) GetReferences() []*Reference {
if x != nil {
return x.References
}
return nil
}
func (x *PublishRequest) GetRecursive() bool {
if x != nil {
return x.Recursive
}
return false
}
func (x *PublishRequest) GetForce() bool {
if x != nil {
return x.Force
}
return false
}
// PublishResponse ответ на запрос публикации записей
type PublishResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Published []*Reference `protobuf:"bytes,2,rep,name=published,proto3" json:"published,omitempty"` // Список опубликованных записей
Notfound []*Reference `protobuf:"bytes,3,rep,name=notfound,proto3" json:"notfound,omitempty"` // Список не найденных записей
Unpublished []*Reference `protobuf:"bytes,4,rep,name=unpublished,proto3" json:"unpublished,omitempty"` // Список не опубликованных записей, требующих публикации
}
func (x *PublishResponse) Reset() {
*x = PublishResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_references_references_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PublishResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PublishResponse) ProtoMessage() {}
func (x *PublishResponse) ProtoReflect() protoreflect.Message {
mi := &file_references_references_proto_msgTypes[4]
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 PublishResponse.ProtoReflect.Descriptor instead.
func (*PublishResponse) Descriptor() ([]byte, []int) {
return file_references_references_proto_rawDescGZIP(), []int{4}
}
func (x *PublishResponse) GetPublished() []*Reference {
if x != nil {
return x.Published
}
return nil
}
func (x *PublishResponse) GetNotfound() []*Reference {
if x != nil {
return x.Notfound
}
return nil
}
func (x *PublishResponse) GetUnpublished() []*Reference {
if x != nil {
return x.Unpublished
}
return nil
}
var File_references_references_proto protoreflect.FileDescriptor
var file_references_references_proto_rawDesc = []byte{
......@@ -230,17 +374,46 @@ var file_references_references_proto_rawDesc = []byte{
0x6f, 0x74, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63,
0x65, 0x73, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x6e, 0x6f,
0x74, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x32, 0x56, 0x0a, 0x0a, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65,
0x6e, 0x63, 0x65, 0x73, 0x12, 0x48, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x1e, 0x2e, 0x63, 0x6f,
0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73,
0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x63, 0x6f,
0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73,
0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3a,
0x5a, 0x38, 0x67, 0x69, 0x74, 0x2e, 0x70, 0x65, 0x72, 0x78, 0x2e, 0x72, 0x75, 0x2f, 0x70, 0x65,
0x72, 0x78, 0x69, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x78, 0x69, 0x73, 0x2d, 0x67, 0x6f, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x3b,
0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x74, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x22, 0xb5, 0x01, 0x0a, 0x0e, 0x50, 0x75, 0x62, 0x6c, 0x69,
0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x70, 0x61,
0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x70, 0x61,
0x63, 0x65, 0x49, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x65, 0x6e, 0x76, 0x5f, 0x69, 0x64, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6e, 0x76, 0x49, 0x64, 0x12, 0x3d, 0x0a, 0x0a, 0x72,
0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65,
0x6e, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0a,
0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65,
0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x72,
0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6f, 0x72, 0x63,
0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x22, 0xca,
0x01, 0x0a, 0x0f, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x3b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x18,
0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e,
0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72,
0x65, 0x6e, 0x63, 0x65, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x12,
0x39, 0x0a, 0x08, 0x6e, 0x6f, 0x74, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e, 0x72, 0x65, 0x66, 0x65,
0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65,
0x52, 0x08, 0x6e, 0x6f, 0x74, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x3f, 0x0a, 0x0b, 0x75, 0x6e,
0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65,
0x6e, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0b,
0x75, 0x6e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x32, 0xac, 0x01, 0x0a, 0x0a,
0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x48, 0x0a, 0x03, 0x47, 0x65,
0x74, 0x12, 0x1e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e, 0x72, 0x65, 0x66, 0x65,
0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e, 0x72, 0x65, 0x66, 0x65,
0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x07, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x12,
0x22, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65,
0x6e, 0x63, 0x65, 0x73, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2e, 0x72, 0x65,
0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69,
0x74, 0x2e, 0x70, 0x65, 0x72, 0x78, 0x2e, 0x72, 0x75, 0x2f, 0x70, 0x65, 0x72, 0x78, 0x69, 0x73,
0x2f, 0x70, 0x65, 0x72, 0x78, 0x69, 0x73, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x3b, 0x72, 0x65, 0x66, 0x65,
0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
......@@ -255,24 +428,32 @@ func file_references_references_proto_rawDescGZIP() []byte {
return file_references_references_proto_rawDescData
}
var file_references_references_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_references_references_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_references_references_proto_goTypes = []interface{}{
(*Reference)(nil), // 0: content.references.Reference
(*GetRequest)(nil), // 1: content.references.GetRequest
(*GetResponse)(nil), // 2: content.references.GetResponse
(*items.Item)(nil), // 3: content.items.Item
(*PublishRequest)(nil), // 3: content.references.PublishRequest
(*PublishResponse)(nil), // 4: content.references.PublishResponse
(*items.Item)(nil), // 5: content.items.Item
}
var file_references_references_proto_depIdxs = []int32{
0, // 0: content.references.GetRequest.references:type_name -> content.references.Reference
3, // 1: content.references.GetResponse.items:type_name -> content.items.Item
5, // 1: content.references.GetResponse.items:type_name -> content.items.Item
0, // 2: content.references.GetResponse.notfound:type_name -> content.references.Reference
1, // 3: content.references.References.Get:input_type -> content.references.GetRequest
2, // 4: content.references.References.Get:output_type -> content.references.GetResponse
4, // [4:5] is the sub-list for method output_type
3, // [3:4] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
0, // 3: content.references.PublishRequest.references:type_name -> content.references.Reference
0, // 4: content.references.PublishResponse.published:type_name -> content.references.Reference
0, // 5: content.references.PublishResponse.notfound:type_name -> content.references.Reference
0, // 6: content.references.PublishResponse.unpublished:type_name -> content.references.Reference
1, // 7: content.references.References.Get:input_type -> content.references.GetRequest
3, // 8: content.references.References.Publish:input_type -> content.references.PublishRequest
2, // 9: content.references.References.Get:output_type -> content.references.GetResponse
4, // 10: content.references.References.Publish:output_type -> content.references.PublishResponse
9, // [9:11] is the sub-list for method output_type
7, // [7:9] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name
7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
}
func init() { file_references_references_proto_init() }
......@@ -317,6 +498,30 @@ func file_references_references_proto_init() {
return nil
}
}
file_references_references_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PublishRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_references_references_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PublishResponse); 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{
......@@ -324,7 +529,7 @@ func file_references_references_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_references_references_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumMessages: 5,
NumExtensions: 0,
NumServices: 1,
},
......
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.21.12
// - protoc v4.23.4
// source: references/references.proto
package references
......@@ -20,13 +20,26 @@ const _ = grpc.SupportPackageIsVersion7
const (
References_Get_FullMethodName = "/content.references.References/Get"
References_Publish_FullMethodName = "/content.references.References/Publish"
)
// ReferencesClient is the client API for References 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 ReferencesClient interface {
// Get возвращает список записей по ссылкам
Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error)
// Publish принимает список ссылок на записи и публикует их с учетом вложенных ссылок.
//
// - В случае если флаг `recursive` установлен в true, то будут рекурсивно опубликованы
// все записи на которые ссылаются найденные записи.
// - Если флаг `recursive` установлен в false, то будут опубликованы записи
// только из списка `references` в случае если они не содержат не опубликованных
// ссылок. В противном случае возвращается список не опубликованных записей `unpublished`
// которые требуют публикации. Список `published` при этом будет пустым. В случае если флаг
// `force` установлен в true, то записи будут опубликованы даже если они содержат
// не опубликованные ссылки.
Publish(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*PublishResponse, error)
}
type referencesClient struct {
......@@ -46,11 +59,32 @@ func (c *referencesClient) Get(ctx context.Context, in *GetRequest, opts ...grpc
return out, nil
}
func (c *referencesClient) Publish(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*PublishResponse, error) {
out := new(PublishResponse)
err := c.cc.Invoke(ctx, References_Publish_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ReferencesServer is the server API for References service.
// All implementations must embed UnimplementedReferencesServer
// for forward compatibility
type ReferencesServer interface {
// Get возвращает список записей по ссылкам
Get(context.Context, *GetRequest) (*GetResponse, error)
// Publish принимает список ссылок на записи и публикует их с учетом вложенных ссылок.
//
// - В случае если флаг `recursive` установлен в true, то будут рекурсивно опубликованы
// все записи на которые ссылаются найденные записи.
// - Если флаг `recursive` установлен в false, то будут опубликованы записи
// только из списка `references` в случае если они не содержат не опубликованных
// ссылок. В противном случае возвращается список не опубликованных записей `unpublished`
// которые требуют публикации. Список `published` при этом будет пустым. В случае если флаг
// `force` установлен в true, то записи будут опубликованы даже если они содержат
// не опубликованные ссылки.
Publish(context.Context, *PublishRequest) (*PublishResponse, error)
mustEmbedUnimplementedReferencesServer()
}
......@@ -61,6 +95,9 @@ type UnimplementedReferencesServer struct {
func (UnimplementedReferencesServer) Get(context.Context, *GetRequest) (*GetResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Get not implemented")
}
func (UnimplementedReferencesServer) Publish(context.Context, *PublishRequest) (*PublishResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Publish not implemented")
}
func (UnimplementedReferencesServer) mustEmbedUnimplementedReferencesServer() {}
// UnsafeReferencesServer may be embedded to opt out of forward compatibility for this service.
......@@ -92,6 +129,24 @@ func _References_Get_Handler(srv interface{}, ctx context.Context, dec func(inte
return interceptor(ctx, in, info, handler)
}
func _References_Publish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PublishRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ReferencesServer).Publish(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: References_Publish_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ReferencesServer).Publish(ctx, req.(*PublishRequest))
}
return interceptor(ctx, in, info, handler)
}
// References_ServiceDesc is the grpc.ServiceDesc for References service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
......@@ -103,6 +158,10 @@ var References_ServiceDesc = grpc.ServiceDesc{
MethodName: "Get",
Handler: _References_Get_Handler,
},
{
MethodName: "Publish",
Handler: _References_Publish_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "references/references.proto",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment