objects

package
v0.0.0-...-afb99dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2021 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithRouterProvider

func ContextWithRouterProvider(ctx context.Context, p RouterProvider) context.Context

ContextWithRouterProvider updates context by adding a RouterProvider object in its values

func ContextWithStore

func ContextWithStore(parent context.Context, db DB) context.Context

func CreateCollection

func CreateCollection(ctx context.Context, collection *pb.Collection, opts CreateCollectionOptions) error

func DeleteCollection

func DeleteCollection(ctx context.Context, id string, opts DeleteCollectionOptions) error

func DeleteObject

func DeleteObject(ctx context.Context, collection string, id string, opts DeleteObjectOptions) error

func GetCollection

func GetCollection(ctx context.Context, id string, opts GetCollectionOptions) (*pb.Collection, error)

func GetObject

func GetObject(ctx context.Context, collection string, id string, opts GetObjectOptions) (*pb.Object, error)

func GetObjectHeader

func GetObjectHeader(ctx context.Context, collection string, id string, opts GetHeaderOptions) (*pb.Header, error)

func HTTPHandleCreateCollection

func HTTPHandleCreateCollection(w http.ResponseWriter, r *http.Request)

func HTTPHandleDeleteCollection

func HTTPHandleDeleteCollection(w http.ResponseWriter, r *http.Request)

func HTTPHandleDeleteObject

func HTTPHandleDeleteObject(w http.ResponseWriter, r *http.Request)

func HTTPHandleGetCollection

func HTTPHandleGetCollection(w http.ResponseWriter, r *http.Request)

func HTTPHandleGetObject

func HTTPHandleGetObject(w http.ResponseWriter, r *http.Request)

func HTTPHandleListCollections

func HTTPHandleListCollections(w http.ResponseWriter, r *http.Request)

func HTTPHandleListObjects

func HTTPHandleListObjects(w http.ResponseWriter, r *http.Request)

func HTTPHandleMoveObject

func HTTPHandleMoveObject(w http.ResponseWriter, r *http.Request)

func HTTPHandlePatchObject

func HTTPHandlePatchObject(w http.ResponseWriter, r *http.Request)

func HTTPHandlePutObject

func HTTPHandlePutObject(w http.ResponseWriter, r *http.Request)

func HTTPHandleSearchObjects

func HTTPHandleSearchObjects(w http.ResponseWriter, r *http.Request)

func ListCollections

func ListCollections(ctx context.Context, opts ListCollectionOptions) ([]*pb.Collection, error)

func Middleware

func Middleware(opt ...MiddlewareOption) mux.MiddlewareFunc

func MoveObject

func MoveObject(ctx context.Context, collection string, objectID string, targetCollection string, accessSecurityRules *pb.PathAccessRules, opts MoveOptions) error

func MuxRouter

func MuxRouter(middleware ...mux.MiddlewareFunc) http.Handler

func NewGRPCHandler

func NewGRPCHandler() pb.ObjectsServer

func NewSQLCollection

func NewSQLCollection(collection *pb.Collection, db *sql.DB, dialect string, tablePrefix string) (*sqlCollection, error)

func PatchObject

func PatchObject(ctx context.Context, collection string, patch *pb.Patch, opts PatchOptions) error

func PutObject

func PutObject(ctx context.Context, collection string, object *pb.Object, accessSecurityRules *pb.PathAccessRules, indexes []*pb.TextIndex, opts PutOptions) (string, error)

Types

type ACLHandler

type ACLHandler struct {
	BaseHandler
}

func (*ACLHandler) CreateCollection

func (p *ACLHandler) CreateCollection(ctx context.Context, collection *pb.Collection, opts CreateCollectionOptions) error

func (*ACLHandler) DeleteCollection

func (p *ACLHandler) DeleteCollection(ctx context.Context, id string, opts DeleteCollectionOptions) error

func (*ACLHandler) DeleteObject

func (p *ACLHandler) DeleteObject(ctx context.Context, collection string, id string, opts DeleteObjectOptions) error

func (*ACLHandler) GetCollection

func (p *ACLHandler) GetCollection(ctx context.Context, id string, opts GetCollectionOptions) (*pb.Collection, error)

func (*ACLHandler) GetObject

func (p *ACLHandler) GetObject(ctx context.Context, collection string, id string, opts GetObjectOptions) (*pb.Object, error)

func (*ACLHandler) GetObjectHeader

func (p *ACLHandler) GetObjectHeader(ctx context.Context, collection string, id string, opts GetHeaderOptions) (*pb.Header, error)

func (*ACLHandler) ListCollections

func (p *ACLHandler) ListCollections(ctx context.Context, opts ListCollectionOptions) ([]*pb.Collection, error)

func (*ACLHandler) ListObjects

func (p *ACLHandler) ListObjects(ctx context.Context, collection string, opts ListOptions) (*Cursor, error)

func (*ACLHandler) MoveObject

func (p *ACLHandler) MoveObject(ctx context.Context, collection string, objectID string, targetCollection string, authorizedUsers *pb.PathAccessRules, opts MoveOptions) error

func (*ACLHandler) PatchObject

func (p *ACLHandler) PatchObject(ctx context.Context, collection string, patch *pb.Patch, opts PatchOptions) error

func (*ACLHandler) PutObject

func (p *ACLHandler) PutObject(ctx context.Context, collection string, object *pb.Object, authorizedUsers *pb.PathAccessRules, indexes []*pb.TextIndex, opts PutOptions) (string, error)

func (*ACLHandler) SearchObjects

func (p *ACLHandler) SearchObjects(ctx context.Context, collection string, query *pb.SearchQuery, opts SearchObjectsOptions) (*Cursor, error)

type BaseHandler

type BaseHandler struct {
	// contains filtered or unexported fields
}

func (*BaseHandler) CreateCollection

func (b *BaseHandler) CreateCollection(ctx context.Context, collection *pb.Collection, opts CreateCollectionOptions) error

func (*BaseHandler) DeleteCollection

func (b *BaseHandler) DeleteCollection(ctx context.Context, id string, opts DeleteCollectionOptions) error

func (*BaseHandler) DeleteObject

func (b *BaseHandler) DeleteObject(ctx context.Context, collection string, id string, opts DeleteObjectOptions) error

func (*BaseHandler) GetCollection

func (b *BaseHandler) GetCollection(ctx context.Context, id string, opts GetCollectionOptions) (*pb.Collection, error)

func (*BaseHandler) GetObject

func (b *BaseHandler) GetObject(ctx context.Context, collection string, id string, opts GetObjectOptions) (*pb.Object, error)

func (*BaseHandler) GetObjectHeader

func (b *BaseHandler) GetObjectHeader(ctx context.Context, collection string, id string, opts GetHeaderOptions) (*pb.Header, error)

func (*BaseHandler) ListCollections

func (b *BaseHandler) ListCollections(ctx context.Context, opts ListCollectionOptions) ([]*pb.Collection, error)

func (*BaseHandler) ListObjects

func (b *BaseHandler) ListObjects(ctx context.Context, collection string, opts ListOptions) (*Cursor, error)

func (*BaseHandler) MoveObject

func (b *BaseHandler) MoveObject(ctx context.Context, collection string, objectID string, targetCollection string, accessSecurityRules *pb.PathAccessRules, opts MoveOptions) error

func (*BaseHandler) PatchObject

func (b *BaseHandler) PatchObject(ctx context.Context, collection string, patch *pb.Patch, opts PatchOptions) error

func (*BaseHandler) PutObject

func (b *BaseHandler) PutObject(ctx context.Context, collection string, object *pb.Object, accessSecurityRules *pb.PathAccessRules, indexes []*pb.TextIndex, opts PutOptions) (string, error)

func (*BaseHandler) SearchObjects

func (b *BaseHandler) SearchObjects(ctx context.Context, collection string, query *pb.SearchQuery, opts SearchObjectsOptions) (*Cursor, error)

type BrowseFunc

type BrowseFunc func() (*pb.Object, error)

func (BrowseFunc) Browse

func (f BrowseFunc) Browse() (*pb.Object, error)

type Browser

type Browser interface {
	Browse() (*pb.Object, error)
}

type ClientProvider

type ClientProvider interface {
	GetClient(ctx context.Context, serviceType uint32) (pb.ObjectsClient, error)
}

func RouterGrpcClientProvider

func RouterGrpcClientProvider(ctx context.Context) ClientProvider

type CloseFunc

type CloseFunc func() error

func (CloseFunc) Close

func (f CloseFunc) Close() error

type Closer

type Closer interface {
	Close() error
}

type CollectionDB

type CollectionDB interface {

	// Save saves object content as JSON in database
	Save(ctx context.Context, object *pb.Object, index ...*pb.TextIndex) error

	// Patch applies patch to object with id equals patch.ID()
	Patch(ctx context.Context, patch *pb.Patch) error

	// Delete removes all content associated with objectID
	Delete(ctx context.Context, objectID string) error

	// List returns a list of at most 'opts.Count' objects
	List(ctx context.Context, opts ListOptions) (*Cursor, error)

	// Get gets the object associated with objectID
	Get(ctx context.Context, objectID string, opts GetObjectOptions) (*pb.Object, error)

	// Info gets header of the object associated with objectID
	Info(ctx context.Context, objectID string) (*pb.Header, error)

	Search(ctx context.Context, query *pb.SearchQuery) (*Cursor, error)

	// Clear removes all objects store
	Clear() error
}

type CollectionOptions

type CollectionOptions struct {
	Name       string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	FullObject bool   `protobuf:"varint,2,opt,name=full_object,json=fullObject,proto3" json:"full_object,omitempty"`
}

type CreateCollectionOptions

type CreateCollectionOptions struct{}

type Cursor

type Cursor struct {
	// contains filtered or unexported fields
}

func ListObjects

func ListObjects(ctx context.Context, collection string, opts ListOptions) (*Cursor, error)

func NewCursor

func NewCursor(browser Browser, closer Closer) *Cursor

func SearchObjects

func SearchObjects(ctx context.Context, collection string, query *pb.SearchQuery, opts SearchObjectsOptions) (*Cursor, error)

func (*Cursor) Browse

func (c *Cursor) Browse() (*pb.Object, error)

func (*Cursor) Close

func (c *Cursor) Close() error

func (*Cursor) GetBrowser

func (c *Cursor) GetBrowser() Browser

func (*Cursor) GetCloser

func (c *Cursor) GetCloser() Closer

func (*Cursor) SetBrowser

func (c *Cursor) SetBrowser(browser Browser)

func (*Cursor) SetCloser

func (c *Cursor) SetCloser(closer Closer)

type CustomRouter

type CustomRouter struct {
	// contains filtered or unexported fields
}

func NewCustomRouter

func NewCustomRouter(exec Handler, opts ...HandlerOption) *CustomRouter

func (*CustomRouter) GetHandler

func (r *CustomRouter) GetHandler(opts ...RouteOption) Handler

type DB

type DB interface {
	CreateCollection(ctx context.Context, collection *pb.Collection) error

	GetCollection(ctx context.Context, id string) (*pb.Collection, error)

	ListCollections(ctx context.Context) ([]*pb.Collection, error)

	DeleteCollection(ctx context.Context, id string) error

	// Save saves object content as JSON in database
	Save(ctx context.Context, collection string, object *pb.Object, index ...*pb.TextIndex) error

	Patch(ctx context.Context, collection string, patch *pb.Patch) error

	// Delete removes all content associated with objectID
	Delete(ctx context.Context, collection string, objectID string) error

	// Get gets the object associated with objectID
	Get(ctx context.Context, collection string, objectID string, opts GetObjectOptions) (*pb.Object, error)

	// Info gets header of the object associated with objectID
	Info(ctx context.Context, collection string, objectID string) (*pb.Header, error)

	// List returns a list of at most 'opts.Count' objects
	List(ctx context.Context, collection string, opts ListOptions) (*Cursor, error)

	Search(ctx context.Context, collection string, query *pb.SearchQuery) (*Cursor, error)
}

func Get

func Get(ctx context.Context) DB

func NewSqlDB

func NewSqlDB(db *sql.DB, dialect string, tablePrefix string) (DB, error)

type DeleteCollectionOptions

type DeleteCollectionOptions struct{}

type DeleteObjectOptions

type DeleteObjectOptions struct{}

type ExecHandler

type ExecHandler struct {
	BaseHandler
}

func (*ExecHandler) CreateCollection

func (e *ExecHandler) CreateCollection(ctx context.Context, collection *pb.Collection, _ CreateCollectionOptions) error

func (*ExecHandler) DeleteCollection

func (e *ExecHandler) DeleteCollection(ctx context.Context, id string, _ DeleteCollectionOptions) error

func (*ExecHandler) DeleteObject

func (e *ExecHandler) DeleteObject(ctx context.Context, collection string, id string, _ DeleteObjectOptions) error

func (*ExecHandler) GetCollection

func (e *ExecHandler) GetCollection(ctx context.Context, id string, _ GetCollectionOptions) (*pb.Collection, error)

func (*ExecHandler) GetObject

func (e *ExecHandler) GetObject(ctx context.Context, collection string, id string, opts GetObjectOptions) (*pb.Object, error)

func (*ExecHandler) GetObjectHeader

func (e *ExecHandler) GetObjectHeader(ctx context.Context, collection string, id string, _ GetHeaderOptions) (*pb.Header, error)

func (*ExecHandler) ListCollections

func (e *ExecHandler) ListCollections(ctx context.Context, _ ListCollectionOptions) ([]*pb.Collection, error)

func (*ExecHandler) ListObjects

func (e *ExecHandler) ListObjects(ctx context.Context, collection string, opts ListOptions) (*Cursor, error)

func (*ExecHandler) MoveObject

func (e *ExecHandler) MoveObject(ctx context.Context, collection string, objectID string, targetCollection string, _ *pb.PathAccessRules, _ MoveOptions) error

func (*ExecHandler) PatchObject

func (e *ExecHandler) PatchObject(ctx context.Context, collection string, patch *pb.Patch, _ PatchOptions) error

func (*ExecHandler) PutObject

func (e *ExecHandler) PutObject(ctx context.Context, collection string, object *pb.Object, _ *pb.PathAccessRules, indexes []*pb.TextIndex, _ PutOptions) (string, error)

func (*ExecHandler) SearchObjects

func (e *ExecHandler) SearchObjects(ctx context.Context, collection string, query *pb.SearchQuery, _ SearchObjectsOptions) (*Cursor, error)

type GetCollectionOptions

type GetCollectionOptions struct{}

type GetHeaderOptions

type GetHeaderOptions struct{}

type GetObjectOptions

type GetObjectOptions struct {
	Info bool   `protobuf:"varint,1,opt,name=info,proto3" json:"info,omitempty"`
	At   string `protobuf:"bytes,2,opt,name=at,proto3" json:"at,omitempty"`
}

type Handler

type Handler interface {
	CreateCollection(ctx context.Context, collection *pb.Collection, opts CreateCollectionOptions) error
	GetCollection(ctx context.Context, id string, opts GetCollectionOptions) (*pb.Collection, error)
	ListCollections(ctx context.Context, opts ListCollectionOptions) ([]*pb.Collection, error)
	DeleteCollection(ctx context.Context, id string, opts DeleteCollectionOptions) error

	PutObject(ctx context.Context, collection string, object *pb.Object, accessSecurityRules *pb.PathAccessRules, indexes []*pb.TextIndex, opts PutOptions) (string, error)
	PatchObject(ctx context.Context, collection string, patch *pb.Patch, opts PatchOptions) error
	MoveObject(ctx context.Context, collection string, objectID string, targetCollection string, accessSecurityRules *pb.PathAccessRules, opts MoveOptions) error
	GetObject(ctx context.Context, collection string, id string, opts GetObjectOptions) (*pb.Object, error)
	GetObjectHeader(ctx context.Context, collection string, id string, opts GetHeaderOptions) (*pb.Header, error)
	DeleteObject(ctx context.Context, collection string, id string, opts DeleteObjectOptions) error
	ListObjects(ctx context.Context, collection string, opts ListOptions) (*Cursor, error)
	SearchObjects(ctx context.Context, collection string, query *pb.SearchQuery, opts SearchObjectsOptions) (*Cursor, error)
}

func GetRouterHandler

func GetRouterHandler(ctx context.Context, opt ...RouteOption) Handler

func NewGRPCObjectsClientHandler

func NewGRPCObjectsClientHandler(nodeType uint32) Handler

NewGRPCObjectsClientHandler creates a router ObjectsHandler that embed that calls a gRPC service to perform final actions

type HandlerOption

type HandlerOption func(*objectsHandlersOptions)

func WithDefaultParamsHandler

func WithDefaultParamsHandler() HandlerOption

func WithDefaultPolicyHandler

func WithDefaultPolicyHandler() HandlerOption

type JsonObject

type JsonObject struct {
	// contains filtered or unexported fields
}

func (*JsonObject) BoolAt

func (s *JsonObject) BoolAt(name string) (bool, error)

func (*JsonObject) Get

func (s *JsonObject) Get(name string) (*JsonObject, error)

func (*JsonObject) GetObject

func (s *JsonObject) GetObject() interface{}

func (*JsonObject) Int

func (s *JsonObject) Int(name string) (int, error)

func (*JsonObject) Int32

func (s *JsonObject) Int32(name string) (int32, error)

func (*JsonObject) Int64

func (s *JsonObject) Int64(name string) (int64, error)

func (*JsonObject) Marshal

func (s *JsonObject) Marshal() ([]byte, error)

func (*JsonObject) String

func (s *JsonObject) String() string

func (*JsonObject) StringAt

func (s *JsonObject) StringAt(name string) (string, error)

func (*JsonObject) ToInt

func (s *JsonObject) ToInt() (int, error)

func (*JsonObject) ToInt32

func (s *JsonObject) ToInt32() (int32, error)

func (*JsonObject) ToInt64

func (s *JsonObject) ToInt64() (int64, error)

func (*JsonObject) ToString

func (s *JsonObject) ToString() (string, error)

type ListCollectionOptions

type ListCollectionOptions struct{}

type ListOptions

type ListOptions struct {
	At     string `protobuf:"bytes,3,opt,name=at,proto3" json:"at,omitempty"`
	Offset int64  `protobuf:"varint,1,opt,name=offset,proto3" json:"offset,omitempty"`
}

type LoadBalancer

type LoadBalancer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*LoadBalancer) GetClient

func (b *LoadBalancer) GetClient(ctx context.Context, serviceType uint32) (pb.ObjectsClient, error)

type MiddlewareOption

type MiddlewareOption func(*middlewareOptions)

func MiddlewareWithDB

func MiddlewareWithDB(db DB) MiddlewareOption

func MiddlewareWithRouterProvider

func MiddlewareWithRouterProvider(provider RouterProvider) MiddlewareOption

type MoveOptions

type MoveOptions struct {
	NewSecurity *pb.PathAccessRules
}

type ParamsHandler

type ParamsHandler struct {
	BaseHandler
}

func (*ParamsHandler) CreateCollection

func (p *ParamsHandler) CreateCollection(ctx context.Context, collection *pb.Collection, opts CreateCollectionOptions) error

func (*ParamsHandler) DeleteCollection

func (p *ParamsHandler) DeleteCollection(ctx context.Context, id string, opts DeleteCollectionOptions) error

func (*ParamsHandler) DeleteObject

func (p *ParamsHandler) DeleteObject(ctx context.Context, collection string, id string, opts DeleteObjectOptions) error

func (*ParamsHandler) GetCollection

func (p *ParamsHandler) GetCollection(ctx context.Context, id string, opts GetCollectionOptions) (*pb.Collection, error)

func (*ParamsHandler) GetObject

func (p *ParamsHandler) GetObject(ctx context.Context, collection string, id string, opts GetObjectOptions) (*pb.Object, error)

func (*ParamsHandler) GetObjectHeader

func (p *ParamsHandler) GetObjectHeader(ctx context.Context, collection string, id string, opts GetHeaderOptions) (*pb.Header, error)

func (*ParamsHandler) ListObjects

func (p *ParamsHandler) ListObjects(ctx context.Context, collection string, opts ListOptions) (*Cursor, error)

func (*ParamsHandler) MoveObject

func (p *ParamsHandler) MoveObject(ctx context.Context, collection string, objectID string, targetCollection string, accessSecurityRules *pb.PathAccessRules, opts MoveOptions) error

func (*ParamsHandler) PatchObject

func (p *ParamsHandler) PatchObject(ctx context.Context, collection string, patch *pb.Patch, opts PatchOptions) error

func (*ParamsHandler) PutObject

func (p *ParamsHandler) PutObject(ctx context.Context, collection string, object *pb.Object, accessSecurityRules *pb.PathAccessRules, indexes []*pb.TextIndex, opts PutOptions) (string, error)

func (*ParamsHandler) SearchObjects

func (p *ParamsHandler) SearchObjects(ctx context.Context, collection string, query *pb.SearchQuery, opts SearchObjectsOptions) (*Cursor, error)

type PatchOptions

type PatchOptions struct{}

type PutOptions

type PutOptions struct{}

type RouteOption

type RouteOption func(*routesOptions)

type RouteProviderFunc

type RouteProviderFunc func(opts ...RouteOption) Handler

func (RouteProviderFunc) GetHandler

func (f RouteProviderFunc) GetHandler(opts ...RouteOption) Handler

type Router

type Router interface {
	// GetHandler returns a sequence of handler
	GetHandler(opts ...RouteOption) Handler
}

func DefaultRouter

func DefaultRouter() Router

type RouterProvideFunc

type RouterProvideFunc func(ctx context.Context) Router

func (RouterProvideFunc) GetRouter

func (f RouterProvideFunc) GetRouter(ctx context.Context) Router

type RouterProvider

type RouterProvider interface {
	//GetRouter returns a router
	GetRouter(ctx context.Context) Router
}

type SearchObjectsOptions

type SearchObjectsOptions struct{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL