Skip to content
Snippets Groups Projects
Commit ff21cb7e authored by ko_oler's avatar ko_oler
Browse files

Обновлен пакет Collections после добавления поля TTL

parent c47f4706
No related branches found
No related tags found
No related merge requests found
Subproject commit d9fd1b7382944ef12019bcab1ad00334d9b90a88
Subproject commit dcb1e741b7515784c6125761d459c23e3b61805f
......@@ -61,6 +61,7 @@ type Collection struct {
Hidden bool `json:"hidden" bson:"hidden"` // Коллекция скрыта в административном интерфейсе
Schema *schema.Schema `json:"schema" bson:"schema"`
Access *Access `json:"access" bson:"-"` // Ограничения на доступ к элементам коллекции. Отсутствие объекта означает неограниченный доступ
TTL time.Duration `json:"ttl" bson:"ttl"` // Время хранения записи в коллекции
// StateInfo отображает состояние коллекции:
// - State: идентификатор состояния коллекции (new/preparing/ready/error/changed)
......@@ -132,6 +133,7 @@ func (c Collection) Clone() *Collection {
Name: c.Name,
NoData: c.NoData,
Hidden: c.Hidden,
TTL: c.TTL,
}
if c.Single != nil {
......
......@@ -13,6 +13,7 @@ import (
pb "git.perx.ru/perxis/perxis-go/proto/collections"
commonpb "git.perx.ru/perxis/perxis-go/proto/common"
jsoniter "github.com/json-iterator/go"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
)
......@@ -58,6 +59,7 @@ func PtrCollectionToProto(coll *service.Collection) (*pb.Collection, error) {
WriteonlyFields: coll.Access.WriteonlyFields,
}
}
protoCollection := &pb.Collection{
Id: coll.ID,
SpaceId: coll.SpaceID,
......@@ -69,6 +71,7 @@ func PtrCollectionToProto(coll *service.Collection) (*pb.Collection, error) {
Access: access,
Hidden: coll.Hidden,
Tags: coll.Tags,
Ttl: durationpb.New(coll.TTL),
}
if coll.StateInfo != nil {
......@@ -127,6 +130,7 @@ func ProtoToPtrCollection(protoCollection *pb.Collection) (*service.Collection,
Access: access,
Hidden: protoCollection.Hidden,
Tags: protoCollection.Tags,
TTL: protoCollection.Ttl.AsDuration(),
}
if protoCollection.StateInfo != nil {
......
......@@ -21,6 +21,7 @@ import (
itemspb "git.perx.ru/perxis/perxis-go/proto/items"
localespb "git.perx.ru/perxis/perxis-go/proto/locales"
"github.com/golang/protobuf/ptypes"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/structpb"
)
......@@ -127,6 +128,7 @@ func PtrCollectionsCollectionToProto(collection *collections.Collection) (*colle
Name: collection.Name,
Single: collection.Single,
System: collection.System,
Ttl: durationpb.New(collection.TTL),
}
if collection.Schema != nil {
b, err := collection.Schema.MarshalJSON()
......@@ -149,6 +151,7 @@ func ProtoToPtrCollectionsCollection(protoCollection *collectionspb.Collection)
Name: protoCollection.Name,
Single: protoCollection.Single,
System: protoCollection.System,
TTL: protoCollection.Ttl.AsDuration(),
}
if protoCollection.Schema != "" {
sch := schema.New()
......
This diff is collapsed.
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.21.12
// source: collections/collections.proto
......@@ -19,15 +19,6 @@ import (
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
Collections_Create_FullMethodName = "/content.collections.Collections/Create"
Collections_Get_FullMethodName = "/content.collections.Collections/Get"
Collections_List_FullMethodName = "/content.collections.Collections/List"
Collections_Update_FullMethodName = "/content.collections.Collections/Update"
Collections_SetSchema_FullMethodName = "/content.collections.Collections/SetSchema"
Collections_Delete_FullMethodName = "/content.collections.Collections/Delete"
)
// CollectionsClient is the client API for Collections 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.
......@@ -50,7 +41,7 @@ func NewCollectionsClient(cc grpc.ClientConnInterface) CollectionsClient {
func (c *collectionsClient) Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) {
out := new(CreateResponse)
err := c.cc.Invoke(ctx, Collections_Create_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/content.collections.Collections/Create", in, out, opts...)
if err != nil {
return nil, err
}
......@@ -59,7 +50,7 @@ func (c *collectionsClient) Create(ctx context.Context, in *CreateRequest, opts
func (c *collectionsClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) {
out := new(GetResponse)
err := c.cc.Invoke(ctx, Collections_Get_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/content.collections.Collections/Get", in, out, opts...)
if err != nil {
return nil, err
}
......@@ -68,7 +59,7 @@ func (c *collectionsClient) Get(ctx context.Context, in *GetRequest, opts ...grp
func (c *collectionsClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) {
out := new(ListResponse)
err := c.cc.Invoke(ctx, Collections_List_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/content.collections.Collections/List", in, out, opts...)
if err != nil {
return nil, err
}
......@@ -77,7 +68,7 @@ func (c *collectionsClient) List(ctx context.Context, in *ListRequest, opts ...g
func (c *collectionsClient) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, Collections_Update_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/content.collections.Collections/Update", in, out, opts...)
if err != nil {
return nil, err
}
......@@ -86,7 +77,7 @@ func (c *collectionsClient) Update(ctx context.Context, in *UpdateRequest, opts
func (c *collectionsClient) SetSchema(ctx context.Context, in *SetSchemaRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, Collections_SetSchema_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/content.collections.Collections/SetSchema", in, out, opts...)
if err != nil {
return nil, err
}
......@@ -95,7 +86,7 @@ func (c *collectionsClient) SetSchema(ctx context.Context, in *SetSchemaRequest,
func (c *collectionsClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, Collections_Delete_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, "/content.collections.Collections/Delete", in, out, opts...)
if err != nil {
return nil, err
}
......@@ -160,7 +151,7 @@ func _Collections_Create_Handler(srv interface{}, ctx context.Context, dec func(
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Collections_Create_FullMethodName,
FullMethod: "/content.collections.Collections/Create",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CollectionsServer).Create(ctx, req.(*CreateRequest))
......@@ -178,7 +169,7 @@ func _Collections_Get_Handler(srv interface{}, ctx context.Context, dec func(int
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Collections_Get_FullMethodName,
FullMethod: "/content.collections.Collections/Get",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CollectionsServer).Get(ctx, req.(*GetRequest))
......@@ -196,7 +187,7 @@ func _Collections_List_Handler(srv interface{}, ctx context.Context, dec func(in
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Collections_List_FullMethodName,
FullMethod: "/content.collections.Collections/List",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CollectionsServer).List(ctx, req.(*ListRequest))
......@@ -214,7 +205,7 @@ func _Collections_Update_Handler(srv interface{}, ctx context.Context, dec func(
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Collections_Update_FullMethodName,
FullMethod: "/content.collections.Collections/Update",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CollectionsServer).Update(ctx, req.(*UpdateRequest))
......@@ -232,7 +223,7 @@ func _Collections_SetSchema_Handler(srv interface{}, ctx context.Context, dec fu
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Collections_SetSchema_FullMethodName,
FullMethod: "/content.collections.Collections/SetSchema",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CollectionsServer).SetSchema(ctx, req.(*SetSchemaRequest))
......@@ -250,7 +241,7 @@ func _Collections_Delete_Handler(srv interface{}, ctx context.Context, dec func(
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Collections_Delete_FullMethodName,
FullMethod: "/content.collections.Collections/Delete",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CollectionsServer).Delete(ctx, req.(*DeleteRequest))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment