dao

package
v4.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package dao provides abstraction of persistence layer used by pydio services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsShared added in v4.0.1

func IsShared(driverName string) (bool, error)

IsShared indicates if a DAO is shared across services or a locked to a local file

func RegisterDAODriver

func RegisterDAODriver(name string, daoF DaoProviderFunc, connF ConnProviderFunc)

RegisterDAODriver registers factories for DAOs and Connections that are storing data on-file (cannot be shared across multiple nodes)

func RegisterIndexerDriver

func RegisterIndexerDriver(name string, daoF IndexerWrapperFunc)

RegisterIndexerDriver registers factories for Indexers

func RegisterSharedDAODriver added in v4.0.1

func RegisterSharedDAODriver(name string, daoF DaoProviderFunc, connF ConnProviderFunc)

RegisterSharedDAODriver registers factories for DAOs and Connections that can be shared across multiple nodes

func UnknownDriverType added in v4.0.1

func UnknownDriverType(name string) error

func UnsupportedDriver added in v4.0.1

func UnsupportedDriver(o DAO) error

func UnsupportedDriverType added in v4.0.1

func UnsupportedDriverType(name string) error

Types

type Conn

type Conn interface{}

func NewConn

func NewConn(ctx context.Context, d string, dsn string) (Conn, error)

type ConnDriver

type ConnDriver interface {
	Open(ctx context.Context, dsn string) (Conn, error)
	GetConn(ctx context.Context) (Conn, error)
	SetMaxConnectionsForWeight(int)
}

type ConnProviderFunc

type ConnProviderFunc func(ctx context.Context, driver, dsn string) ConnDriver

type DAO

type DAO interface {
	registry.Dao

	Init(context.Context, configx.Values) error
	GetConn(context.Context) (Conn, error)
	SetConn(context.Context, Conn)
	CloseConn(context.Context) error

	// Prefix is used to prevent collision between table names
	// in case this DAO accesses a shared DB.
	Prefix() string
	// LocalAccess returns true if DAO relies on an on-file DB
	LocalAccess() bool
	// Stats may return info about the underlying driver/conn
	Stats() map[string]interface{}
}

DAO interface definition

func AbstractDAO

func AbstractDAO(conn Conn, driver, dsn, prefix string) DAO

AbstractDAO returns a reference to a newly created struct that contains the necessary information to access a database. Prefix parameter is used to specify a prefix to avoid collision between table names in case this DAO accesses a shared DB: it thus will be an empty string in most of the cases.

func InitDAO

func InitDAO(ctx context.Context, driver, dsn, prefix string, wrapper DaoWrapperFunc, cfg ...configx.Values) (DAO, error)

InitDAO finalize DAO creation based on registered drivers

func InitIndexer

func InitIndexer(ctx context.Context, driver, dsn, prefix string, wrapper DaoWrapperFunc, cfg ...configx.Values) (DAO, error)

InitIndexer looks up in the register to initialize a DAO and wrap it as an IndexDAO

type DaoProviderFunc

type DaoProviderFunc func(ctx context.Context, driver, dsn, prefix string) (DAO, error)

type DaoWrapperFunc added in v4.0.1

type DaoWrapperFunc func(context.Context, DAO) (DAO, error)

type DriverProviderFunc

type DriverProviderFunc func() (string, string)

type FacetParser

type FacetParser interface {
	UnmarshalFacet(data interface{}, facets chan interface{})
	FlushCustomFacets() []interface{}
}

FacetParser adds additional capacities to IndexCodex for understanding search results Facets

type IndexCodex

type IndexCodex interface {
	// Marshal prepares an document for storing in index
	Marshal(input interface{}) (interface{}, error)
	// Unmarshal decodes a document found in index
	Unmarshal(indexed interface{}) (interface{}, error)
	// BuildQuery prepares a query to be executed. It returns a request object and optionnaly an aggregationRequest object
	BuildQuery(query interface{}, offset, limit int32) (interface{}, interface{}, error)
	// GetModel reads initialization schema to be loaded
	GetModel(sc configx.Values) (interface{}, bool)
}

IndexCodex is the coder/decoder used by an Indexer.

type IndexDAO

type IndexDAO interface {
	DAO
	// SetCodex sets the IndexCodex to be used for marshalling/unmarshalling data. Can be locally overriden during FindMany requests.
	SetCodex(c IndexCodex)
	// InsertOne stores one document. Write operations may be batched underneath.
	InsertOne(ctx context.Context, data interface{}) error
	// DeleteOne deletes one document. It can only be used if documents are providing IDs.
	DeleteOne(ctx context.Context, data interface{}) error
	// Flush triggers internal buffers to be written to storage
	Flush(ctx context.Context) error
	// DeleteMany deletes documents by a search query.
	DeleteMany(ctx context.Context, query interface{}) (int32, error)
	// FindMany sends a search query to indexer. A custom IndexCodex can be used to accumulate some information during results parsing.
	FindMany(ctx context.Context, query interface{}, offset, limit int32, customCodec IndexCodex) (chan interface{}, error)
	// Resync should clear the index and rewrite it from scratch. Used by bolt implementations for defragmentation.
	Resync(ctx context.Context, logger func(string)) error
	// Truncate should free some disk space. Used by bleve implementation in conjunction with rotationSize parameter.
	Truncate(ctx context.Context, max int64, logger func(string)) error
	// Close closes the index connection
	Close(ctx context.Context) error
}

IndexDAO is a rich DAO with ready-to-use inserts + search capacities. It must be initialised with a proper DAO and a proper IndexCodex.

type IndexIDProvider

type IndexIDProvider interface {
	IndexID() string
}

IndexIDProvider can be implemented by marshaled data to be indexed for providing an index ID.

type IndexerWrapperFunc

type IndexerWrapperFunc func(context.Context, DAO) (IndexDAO, error)

type MigratorFunc

type MigratorFunc func(from DAO, to DAO, dryRun bool, status chan MigratorStatus) (map[string]int, error)

type MigratorStatus added in v4.0.1

type MigratorStatus struct {
	Status string
	Total  int64
	Count  int64
}

type QueryOptionsProvider

type QueryOptionsProvider interface {
	BuildQueryOptions(query interface{}, offset, limit int32) (interface{}, error)
}

QueryOptionsProvider adds additional capacities to IndexCodex for building search Query

type UnknownDriverTypeErr added in v4.0.1

type UnknownDriverTypeErr struct {
	Driver string
}

func (*UnknownDriverTypeErr) Error added in v4.0.1

func (u *UnknownDriverTypeErr) Error() string

type UnsupportedDriverTypeErr added in v4.0.1

type UnsupportedDriverTypeErr struct {
	Driver string
}

func (*UnsupportedDriverTypeErr) Error added in v4.0.1

func (u *UnsupportedDriverTypeErr) Error() string

Directories

Path Synopsis
Package bleve provides tools for using Bolt as a standard persistence layer for services.
Package bleve provides tools for using Bolt as a standard persistence layer for services.
Package boltdb provides tools for using Bolt as a standard persistence layer for services
Package boltdb provides tools for using Bolt as a standard persistence layer for services

Jump to

Keyboard shortcuts

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