mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-07-19 12:04:09 -04:00
Migrate proto files for store and adjust paths
This commit is contained in:
@@ -13,6 +13,9 @@ import (
|
||||
accountsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/accounts/v1"
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
storemsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/store/v1"
|
||||
storesvc "github.com/owncloud/ocis/protogen/gen/ocis/services/store/v1"
|
||||
|
||||
"github.com/asim/go-micro/plugins/client/grpc/v4"
|
||||
revauser "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||
@@ -27,7 +30,6 @@ import (
|
||||
"github.com/owncloud/ocis/ocs/pkg/service/v0/data"
|
||||
"github.com/owncloud/ocis/ocs/pkg/service/v0/response"
|
||||
ocstracing "github.com/owncloud/ocis/ocs/pkg/tracing"
|
||||
storepb "github.com/owncloud/ocis/store/pkg/proto/v0"
|
||||
"github.com/pkg/errors"
|
||||
merrors "go-micro.dev/v4/errors"
|
||||
"google.golang.org/genproto/protobuf/field_mask"
|
||||
@@ -653,9 +655,9 @@ func (o Ocs) GetSigningKey(w http.ResponseWriter, r *http.Request) {
|
||||
// use the user's UUID
|
||||
userID := u.Id.OpaqueId
|
||||
|
||||
c := storepb.NewStoreService("com.owncloud.api.store", grpc.NewClient())
|
||||
res, err := c.Read(r.Context(), &storepb.ReadRequest{
|
||||
Options: &storepb.ReadOptions{
|
||||
c := storesvc.NewStoreService("com.owncloud.api.store", grpc.NewClient())
|
||||
res, err := c.Read(r.Context(), &storesvc.ReadRequest{
|
||||
Options: &storemsg.ReadOptions{
|
||||
Database: "proxy",
|
||||
Table: "signing-keys",
|
||||
},
|
||||
@@ -687,12 +689,12 @@ func (o Ocs) GetSigningKey(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
signingKey := hex.EncodeToString(key)
|
||||
|
||||
_, err = c.Write(r.Context(), &storepb.WriteRequest{
|
||||
Options: &storepb.WriteOptions{
|
||||
_, err = c.Write(r.Context(), &storesvc.WriteRequest{
|
||||
Options: &storemsg.WriteOptions{
|
||||
Database: "proxy",
|
||||
Table: "signing-keys",
|
||||
},
|
||||
Record: &storepb.Record{
|
||||
Record: &storemsg.Record{
|
||||
Key: userID,
|
||||
Value: []byte(signingKey),
|
||||
// TODO Expiry?
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
|
||||
storesvc "github.com/owncloud/ocis/protogen/gen/ocis/services/store/v1"
|
||||
|
||||
"github.com/coreos/go-oidc/v3/oidc"
|
||||
"github.com/cs3org/reva/pkg/token/manager/jwt"
|
||||
chimiddleware "github.com/go-chi/chi/v5/middleware"
|
||||
@@ -30,7 +32,6 @@ import (
|
||||
proxyHTTP "github.com/owncloud/ocis/proxy/pkg/server/http"
|
||||
"github.com/owncloud/ocis/proxy/pkg/tracing"
|
||||
"github.com/owncloud/ocis/proxy/pkg/user/backend"
|
||||
storepb "github.com/owncloud/ocis/store/pkg/proto/v0"
|
||||
"github.com/urfave/cli/v2"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
@@ -152,7 +153,7 @@ func loadMiddlewares(ctx context.Context, logger log.Logger, cfg *config.Config)
|
||||
logger.Fatal().Msgf("Invalid accounts backend type '%s'", cfg.AccountBackend)
|
||||
}
|
||||
|
||||
storeClient := storepb.NewStoreService("com.owncloud.api.store", grpc.DefaultClient)
|
||||
storeClient := storesvc.NewStoreService("com.owncloud.api.store", grpc.DefaultClient)
|
||||
if err != nil {
|
||||
logger.Error().Err(err).
|
||||
Str("gateway", cfg.Reva.Address).
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
|
||||
accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v1"
|
||||
settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v1"
|
||||
storesvc "github.com/owncloud/ocis/protogen/gen/ocis/services/store/v1"
|
||||
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/proxy/pkg/config"
|
||||
storepb "github.com/owncloud/ocis/store/pkg/proto/v0"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -41,7 +41,7 @@ type Options struct {
|
||||
// RevaGatewayClient to send requests to the reva gateway
|
||||
RevaGatewayClient gateway.GatewayAPIClient
|
||||
// Store for persisting data
|
||||
Store storepb.StoreService
|
||||
Store storesvc.StoreService
|
||||
// PreSignedURLConfig to configure the middleware
|
||||
PreSignedURLConfig config.PreSignedURL
|
||||
// UserOIDCClaim to read from the oidc claims
|
||||
@@ -142,7 +142,7 @@ func RevaGatewayClient(gc gateway.GatewayAPIClient) Option {
|
||||
}
|
||||
|
||||
// Store provides a function to set the store option.
|
||||
func Store(sc storepb.StoreService) Option {
|
||||
func Store(sc storesvc.StoreService) Option {
|
||||
return func(o *Options) {
|
||||
o.Store = sc
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@ import (
|
||||
|
||||
revactx "github.com/cs3org/reva/pkg/ctx"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
storemsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/store/v1"
|
||||
storesvc "github.com/owncloud/ocis/protogen/gen/ocis/services/store/v1"
|
||||
"github.com/owncloud/ocis/proxy/pkg/config"
|
||||
"github.com/owncloud/ocis/proxy/pkg/user/backend"
|
||||
store "github.com/owncloud/ocis/store/pkg/proto/v0"
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
)
|
||||
|
||||
@@ -39,7 +40,7 @@ type signedURLAuth struct {
|
||||
logger log.Logger
|
||||
preSignedURLConfig config.PreSignedURL
|
||||
userProvider backend.UserBackend
|
||||
store store.StoreService
|
||||
store storesvc.StoreService
|
||||
}
|
||||
|
||||
func (m signedURLAuth) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
@@ -197,8 +198,8 @@ func (m signedURLAuth) createSignature(url string, signingKey []byte) string {
|
||||
}
|
||||
|
||||
func (m signedURLAuth) getSigningKey(ctx context.Context, ocisID string) ([]byte, error) {
|
||||
res, err := m.store.Read(ctx, &store.ReadRequest{
|
||||
Options: &store.ReadOptions{
|
||||
res, err := m.store.Read(ctx, &storesvc.ReadRequest{
|
||||
Options: &storemsg.ReadOptions{
|
||||
Database: "proxy",
|
||||
Table: "signing-keys",
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,248 +0,0 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: proto/v0/store.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
|
||||
proto "google.golang.org/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "go-micro.dev/v4/api"
|
||||
client "go-micro.dev/v4/client"
|
||||
server "go-micro.dev/v4/server"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ api.Endpoint
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Api Endpoints for Store service
|
||||
|
||||
func NewStoreEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{}
|
||||
}
|
||||
|
||||
// Client API for Store service
|
||||
|
||||
type StoreService interface {
|
||||
Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error)
|
||||
Write(ctx context.Context, in *WriteRequest, opts ...client.CallOption) (*WriteResponse, error)
|
||||
Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
|
||||
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (Store_ListService, error)
|
||||
Databases(ctx context.Context, in *DatabasesRequest, opts ...client.CallOption) (*DatabasesResponse, error)
|
||||
Tables(ctx context.Context, in *TablesRequest, opts ...client.CallOption) (*TablesResponse, error)
|
||||
}
|
||||
|
||||
type storeService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewStoreService(name string, c client.Client) StoreService {
|
||||
return &storeService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *storeService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Store.Read", in)
|
||||
out := new(ReadResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *storeService) Write(ctx context.Context, in *WriteRequest, opts ...client.CallOption) (*WriteResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Store.Write", in)
|
||||
out := new(WriteResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *storeService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Store.Delete", in)
|
||||
out := new(DeleteResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *storeService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (Store_ListService, error) {
|
||||
req := c.c.NewRequest(c.name, "Store.List", &ListRequest{})
|
||||
stream, err := c.c.Stream(ctx, req, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := stream.Send(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &storeServiceList{stream}, nil
|
||||
}
|
||||
|
||||
type Store_ListService interface {
|
||||
Context() context.Context
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Recv() (*ListResponse, error)
|
||||
}
|
||||
|
||||
type storeServiceList struct {
|
||||
stream client.Stream
|
||||
}
|
||||
|
||||
func (x *storeServiceList) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *storeServiceList) Context() context.Context {
|
||||
return x.stream.Context()
|
||||
}
|
||||
|
||||
func (x *storeServiceList) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *storeServiceList) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *storeServiceList) Recv() (*ListResponse, error) {
|
||||
m := new(ListResponse)
|
||||
err := x.stream.Recv(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (c *storeService) Databases(ctx context.Context, in *DatabasesRequest, opts ...client.CallOption) (*DatabasesResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Store.Databases", in)
|
||||
out := new(DatabasesResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *storeService) Tables(ctx context.Context, in *TablesRequest, opts ...client.CallOption) (*TablesResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Store.Tables", in)
|
||||
out := new(TablesResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Store service
|
||||
|
||||
type StoreHandler interface {
|
||||
Read(context.Context, *ReadRequest, *ReadResponse) error
|
||||
Write(context.Context, *WriteRequest, *WriteResponse) error
|
||||
Delete(context.Context, *DeleteRequest, *DeleteResponse) error
|
||||
List(context.Context, *ListRequest, Store_ListStream) error
|
||||
Databases(context.Context, *DatabasesRequest, *DatabasesResponse) error
|
||||
Tables(context.Context, *TablesRequest, *TablesResponse) error
|
||||
}
|
||||
|
||||
func RegisterStoreHandler(s server.Server, hdlr StoreHandler, opts ...server.HandlerOption) error {
|
||||
type store interface {
|
||||
Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error
|
||||
Write(ctx context.Context, in *WriteRequest, out *WriteResponse) error
|
||||
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
|
||||
List(ctx context.Context, stream server.Stream) error
|
||||
Databases(ctx context.Context, in *DatabasesRequest, out *DatabasesResponse) error
|
||||
Tables(ctx context.Context, in *TablesRequest, out *TablesResponse) error
|
||||
}
|
||||
type Store struct {
|
||||
store
|
||||
}
|
||||
h := &storeHandler{hdlr}
|
||||
return s.Handle(s.NewHandler(&Store{h}, opts...))
|
||||
}
|
||||
|
||||
type storeHandler struct {
|
||||
StoreHandler
|
||||
}
|
||||
|
||||
func (h *storeHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error {
|
||||
return h.StoreHandler.Read(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *storeHandler) Write(ctx context.Context, in *WriteRequest, out *WriteResponse) error {
|
||||
return h.StoreHandler.Write(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *storeHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error {
|
||||
return h.StoreHandler.Delete(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *storeHandler) List(ctx context.Context, stream server.Stream) error {
|
||||
m := new(ListRequest)
|
||||
if err := stream.Recv(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return h.StoreHandler.List(ctx, m, &storeListStream{stream})
|
||||
}
|
||||
|
||||
type Store_ListStream interface {
|
||||
Context() context.Context
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Send(*ListResponse) error
|
||||
}
|
||||
|
||||
type storeListStream struct {
|
||||
stream server.Stream
|
||||
}
|
||||
|
||||
func (x *storeListStream) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *storeListStream) Context() context.Context {
|
||||
return x.stream.Context()
|
||||
}
|
||||
|
||||
func (x *storeListStream) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *storeListStream) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *storeListStream) Send(m *ListResponse) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (h *storeHandler) Databases(ctx context.Context, in *DatabasesRequest, out *DatabasesResponse) error {
|
||||
return h.StoreHandler.Databases(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *storeHandler) Tables(ctx context.Context, in *TablesRequest, out *TablesResponse) error {
|
||||
return h.StoreHandler.Tables(ctx, in, out)
|
||||
}
|
||||
@@ -1,242 +0,0 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "ownCloud Infinite Scale store",
|
||||
"version": "1.0.0",
|
||||
"contact": {
|
||||
"name": "ownCloud GmbH",
|
||||
"url": "https://github.com/owncloud/ocis",
|
||||
"email": "support@owncloud.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache-2.0",
|
||||
"url": "https://github.com/owncloud/ocis/blob/master/LICENSE"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "Store"
|
||||
}
|
||||
],
|
||||
"schemes": [
|
||||
"http",
|
||||
"https"
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"paths": {},
|
||||
"definitions": {
|
||||
"protobufAny": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@type": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"rpcStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"details": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/protobufAny"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0DatabasesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"databases": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0DeleteOptions": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"database": {
|
||||
"type": "string"
|
||||
},
|
||||
"table": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0DeleteResponse": {
|
||||
"type": "object"
|
||||
},
|
||||
"v0Field": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"title": "type of value e.g string, int, int64, bool, float64"
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"title": "the actual value"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0ListOptions": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"database": {
|
||||
"type": "string"
|
||||
},
|
||||
"table": {
|
||||
"type": "string"
|
||||
},
|
||||
"prefix": {
|
||||
"type": "string"
|
||||
},
|
||||
"suffix": {
|
||||
"type": "string"
|
||||
},
|
||||
"limit": {
|
||||
"type": "string",
|
||||
"format": "uint64"
|
||||
},
|
||||
"offset": {
|
||||
"type": "string",
|
||||
"format": "uint64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0ListResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"keys": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0ReadOptions": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"database": {
|
||||
"type": "string"
|
||||
},
|
||||
"table": {
|
||||
"type": "string"
|
||||
},
|
||||
"prefix": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"suffix": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"limit": {
|
||||
"type": "string",
|
||||
"format": "uint64"
|
||||
},
|
||||
"offset": {
|
||||
"type": "string",
|
||||
"format": "uint64"
|
||||
},
|
||||
"where": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/v0Field"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0ReadResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"records": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/v0Record"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0Record": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"key": {
|
||||
"type": "string",
|
||||
"title": "key of the recorda"
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"format": "byte",
|
||||
"title": "value in the record"
|
||||
},
|
||||
"expiry": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"title": "time.Duration (signed int64 nanoseconds)"
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/v0Field"
|
||||
},
|
||||
"title": "the associated metadata"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0TablesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tables": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0WriteOptions": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"database": {
|
||||
"type": "string"
|
||||
},
|
||||
"table": {
|
||||
"type": "string"
|
||||
},
|
||||
"expiry": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"title": "time.Time"
|
||||
},
|
||||
"ttl": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"title": "time.Duration"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v0WriteResponse": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"externalDocs": {
|
||||
"description": "Developer Manual",
|
||||
"url": "https://owncloud.dev/extensions/store/"
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package grpc
|
||||
import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
"github.com/owncloud/ocis/store/pkg/proto/v0"
|
||||
storesvc "github.com/owncloud/ocis/protogen/gen/ocis/services/store/v1"
|
||||
svc "github.com/owncloud/ocis/store/pkg/service/v0"
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ func Server(opts ...Option) grpc.Service {
|
||||
if err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not initialize service handler")
|
||||
}
|
||||
if err = proto.RegisterStoreHandler(service.Server(), hdlr); err != nil {
|
||||
if err = storesvc.RegisterStoreHandler(service.Server(), hdlr); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not register service handler")
|
||||
}
|
||||
|
||||
|
||||
@@ -10,17 +10,18 @@ import (
|
||||
"github.com/blevesearch/bleve/v2"
|
||||
"github.com/blevesearch/bleve/v2/analysis/analyzer/keyword"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
storemsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/store/v1"
|
||||
storesvc "github.com/owncloud/ocis/protogen/gen/ocis/services/store/v1"
|
||||
"github.com/owncloud/ocis/store/pkg/config"
|
||||
"github.com/owncloud/ocis/store/pkg/proto/v0"
|
||||
merrors "go-micro.dev/v4/errors"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
// BleveDocument wraps the generated Record.Metadata and adds a property that is used to distinguish documents in the index.
|
||||
type BleveDocument struct {
|
||||
Metadata map[string]*proto.Field `json:"metadata"`
|
||||
Database string `json:"database"`
|
||||
Table string `json:"table"`
|
||||
Metadata map[string]*storemsg.Field `json:"metadata"`
|
||||
Database string `json:"database"`
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
// New returns a new instance of Service
|
||||
@@ -77,13 +78,13 @@ type Service struct {
|
||||
}
|
||||
|
||||
// Read implements the StoreHandler interface.
|
||||
func (s *Service) Read(c context.Context, rreq *proto.ReadRequest, rres *proto.ReadResponse) error {
|
||||
func (s *Service) Read(c context.Context, rreq *storesvc.ReadRequest, rres *storesvc.ReadResponse) error {
|
||||
if len(rreq.Key) != 0 {
|
||||
id := getID(rreq.Options.Database, rreq.Options.Table, rreq.Key)
|
||||
file := filepath.Join(s.Config.Datapath, "databases", id)
|
||||
|
||||
var data []byte
|
||||
rec := &proto.Record{}
|
||||
rec := &storemsg.Record{}
|
||||
data, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
return merrors.NotFound(s.id, "could not read record")
|
||||
@@ -123,7 +124,7 @@ func (s *Service) Read(c context.Context, rreq *proto.ReadRequest, rres *proto.R
|
||||
}
|
||||
|
||||
for _, hit := range searchResult.Hits {
|
||||
rec := &proto.Record{}
|
||||
rec := &storemsg.Record{}
|
||||
|
||||
dest := filepath.Join(s.Config.Datapath, "databases", hit.ID)
|
||||
|
||||
@@ -148,7 +149,7 @@ func (s *Service) Read(c context.Context, rreq *proto.ReadRequest, rres *proto.R
|
||||
}
|
||||
|
||||
// Write implements the StoreHandler interface.
|
||||
func (s *Service) Write(c context.Context, wreq *proto.WriteRequest, wres *proto.WriteResponse) error {
|
||||
func (s *Service) Write(c context.Context, wreq *storesvc.WriteRequest, wres *storesvc.WriteResponse) error {
|
||||
id := getID(wreq.Options.Database, wreq.Options.Table, wreq.Record.Key)
|
||||
file := filepath.Join(s.Config.Datapath, "databases", id)
|
||||
|
||||
@@ -181,7 +182,7 @@ func (s *Service) Write(c context.Context, wreq *proto.WriteRequest, wres *proto
|
||||
}
|
||||
|
||||
// Delete implements the StoreHandler interface.
|
||||
func (s *Service) Delete(c context.Context, dreq *proto.DeleteRequest, dres *proto.DeleteResponse) error {
|
||||
func (s *Service) Delete(c context.Context, dreq *storesvc.DeleteRequest, dres *storesvc.DeleteResponse) error {
|
||||
id := getID(dreq.Options.Database, dreq.Options.Table, dreq.Key)
|
||||
file := filepath.Join(s.Config.Datapath, "databases", id)
|
||||
if err := os.Remove(file); err != nil {
|
||||
@@ -201,12 +202,12 @@ func (s *Service) Delete(c context.Context, dreq *proto.DeleteRequest, dres *pro
|
||||
}
|
||||
|
||||
// List implements the StoreHandler interface.
|
||||
func (s *Service) List(context.Context, *proto.ListRequest, proto.Store_ListStream) error {
|
||||
func (s *Service) List(context.Context, *storesvc.ListRequest, storesvc.Store_ListStream) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Databases implements the StoreHandler interface.
|
||||
func (s *Service) Databases(c context.Context, dbreq *proto.DatabasesRequest, dbres *proto.DatabasesResponse) error {
|
||||
func (s *Service) Databases(c context.Context, dbreq *storesvc.DatabasesRequest, dbres *storesvc.DatabasesResponse) error {
|
||||
file := filepath.Join(s.Config.Datapath, "databases")
|
||||
f, err := os.Open(file)
|
||||
if err != nil {
|
||||
@@ -224,7 +225,7 @@ func (s *Service) Databases(c context.Context, dbreq *proto.DatabasesRequest, db
|
||||
}
|
||||
|
||||
// Tables implements the StoreHandler interface.
|
||||
func (s *Service) Tables(ctx context.Context, in *proto.TablesRequest, out *proto.TablesResponse) error {
|
||||
func (s *Service) Tables(ctx context.Context, in *storesvc.TablesRequest, out *storesvc.TablesResponse) error {
|
||||
file := filepath.Join(s.Config.Datapath, "databases", in.Database)
|
||||
f, err := os.Open(file)
|
||||
if err != nil {
|
||||
@@ -300,7 +301,7 @@ func (s Service) indexRecords(recordsDir string) (err error) {
|
||||
|
||||
// read record
|
||||
var data []byte
|
||||
rec := &proto.Record{}
|
||||
rec := &storemsg.Record{}
|
||||
data, err = ioutil.ReadFile(kp)
|
||||
if err != nil {
|
||||
s.log.Error().Err(err).Str("id", id).Msg("could not read record")
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package com.owncloud.ocis.store.v0;
|
||||
|
||||
option go_package = "github.com/owncloud/ocis/store/pkg/proto/v0;proto";
|
||||
|
||||
import "protoc-gen-openapiv2/options/annotations.proto";
|
||||
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
|
||||
info: {
|
||||
title: "ownCloud Infinite Scale store";
|
||||
version: "1.0.0";
|
||||
contact: {
|
||||
name: "ownCloud GmbH";
|
||||
url: "https://github.com/owncloud/ocis";
|
||||
email: "support@owncloud.com";
|
||||
};
|
||||
license: {
|
||||
name: "Apache-2.0";
|
||||
url: "https://github.com/owncloud/ocis/blob/master/LICENSE";
|
||||
};
|
||||
};
|
||||
schemes: HTTP;
|
||||
schemes: HTTPS;
|
||||
consumes: "application/json";
|
||||
produces: "application/json";
|
||||
external_docs: {
|
||||
description: "Developer Manual";
|
||||
url: "https://owncloud.dev/extensions/store/";
|
||||
};
|
||||
};
|
||||
|
||||
service Store {
|
||||
rpc Read(ReadRequest) returns (ReadResponse) {};
|
||||
rpc Write(WriteRequest) returns (WriteResponse) {};
|
||||
rpc Delete(DeleteRequest) returns (DeleteResponse) {};
|
||||
rpc List(ListRequest) returns (stream ListResponse) {};
|
||||
rpc Databases(DatabasesRequest) returns (DatabasesResponse) {};
|
||||
rpc Tables(TablesRequest) returns (TablesResponse) {};
|
||||
}
|
||||
|
||||
message Field {
|
||||
// type of value e.g string, int, int64, bool, float64
|
||||
string type = 1;
|
||||
// the actual value
|
||||
string value = 2;
|
||||
}
|
||||
|
||||
message Record {
|
||||
// key of the recorda
|
||||
string key = 1;
|
||||
// value in the record
|
||||
bytes value = 2;
|
||||
// time.Duration (signed int64 nanoseconds)
|
||||
int64 expiry = 3;
|
||||
// the associated metadata
|
||||
map<string,Field> metadata = 4;
|
||||
}
|
||||
|
||||
message ReadOptions {
|
||||
string database = 1;
|
||||
string table = 2;
|
||||
bool prefix = 3;
|
||||
bool suffix = 4;
|
||||
uint64 limit = 5;
|
||||
uint64 offset = 6;
|
||||
map<string,Field> where = 7;
|
||||
}
|
||||
|
||||
message ReadRequest {
|
||||
string key = 1;
|
||||
ReadOptions options = 2;
|
||||
}
|
||||
|
||||
message ReadResponse {
|
||||
repeated Record records = 1;
|
||||
}
|
||||
|
||||
message WriteOptions {
|
||||
string database = 1;
|
||||
string table = 2;
|
||||
// time.Time
|
||||
int64 expiry = 3;
|
||||
// time.Duration
|
||||
int64 ttl = 4;
|
||||
}
|
||||
|
||||
message WriteRequest {
|
||||
Record record = 1;
|
||||
WriteOptions options = 2;
|
||||
}
|
||||
|
||||
message WriteResponse {}
|
||||
|
||||
message DeleteOptions {
|
||||
string database = 1;
|
||||
string table = 2;
|
||||
}
|
||||
|
||||
message DeleteRequest {
|
||||
string key = 1;
|
||||
DeleteOptions options = 2;
|
||||
}
|
||||
|
||||
message DeleteResponse {}
|
||||
|
||||
message ListOptions {
|
||||
string database = 1;
|
||||
string table = 2;
|
||||
string prefix = 3;
|
||||
string suffix = 4;
|
||||
uint64 limit = 5;
|
||||
uint64 offset = 6;
|
||||
}
|
||||
|
||||
|
||||
message ListRequest {
|
||||
ListOptions options = 1;
|
||||
}
|
||||
|
||||
message ListResponse {
|
||||
reserved 1; //repeated Record records = 1;
|
||||
repeated string keys = 2;
|
||||
}
|
||||
|
||||
message DatabasesRequest {}
|
||||
|
||||
message DatabasesResponse {
|
||||
repeated string databases = 1;
|
||||
}
|
||||
|
||||
message TablesRequest {
|
||||
string database = 1;
|
||||
}
|
||||
|
||||
message TablesResponse {
|
||||
repeated string tables = 1;
|
||||
}
|
||||
Reference in New Issue
Block a user