database

package
v0.0.0-...-64a5f29 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDatabase

func RegisterDatabase(ctx context.Context, scheme string, init_func DatabaseInitializationFunc) error

RegisterDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Database` instances by the `NewDatabase` method.

func Schemes

func Schemes() []string

Schemes returns the list of schemes that have been registered.

Types

type Database

type Database interface {
	AddURI(context.Context, *uri.URI) error
	GetURIWithSourceURL(context.Context, string) (*uri.URI, error)
	GetURIWithShortURL(context.Context, string) (*uri.URI, error)
	SetLogger(context.Context, *log.Logger) error
}

func NewDatabase

func NewDatabase(ctx context.Context, uri string) (Database, error)

NewDatabase returns a new `Database` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `DatabaseInitializationFunc` function used to instantiate the new `Database`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterDatabase` method.

func NewDocstoreDatabase

func NewDocstoreDatabase(ctx context.Context, uri string) (Database, error)

type DatabaseInitializationFunc

type DatabaseInitializationFunc func(ctx context.Context, uri string) (Database, error)

DatabaseInitializationFunc is a function defined by individual database package and used to create an instance of that database

type DocstoreDatabase

type DocstoreDatabase struct {
	Database
	// contains filtered or unexported fields
}

func (*DocstoreDatabase) AddURI

func (db *DocstoreDatabase) AddURI(ctx context.Context, u *uri.URI) error

func (*DocstoreDatabase) GetURIWithShortURL

func (db *DocstoreDatabase) GetURIWithShortURL(ctx context.Context, short_url string) (*uri.URI, error)

func (*DocstoreDatabase) GetURIWithSourceURL

func (db *DocstoreDatabase) GetURIWithSourceURL(ctx context.Context, source_url string) (*uri.URI, error)

func (*DocstoreDatabase) SetLogger

func (db *DocstoreDatabase) SetLogger(ctx context.Context, logger *log.Logger) error

Jump to

Keyboard shortcuts

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