ferretdb

package
Version: v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package ferretdb provides embeddable FerretDB implementation.

Example
f, err := New(&Config{
	Handler:       "pg",
	PostgreSQLURL: "postgres://postgres@127.0.0.1:5432/ferretdb",
})
if err != nil {
	log.Fatal(err)
}

go f.Run(context.Background())

uri := f.MongoDBURI()
fmt.Println(uri)

// Use MongoDB URI as usual. For example:
//
// import "go.mongodb.org/mongo-driver/mongo"
//
// [...]
//
// mongo.Connect(ctx, options.Client().ApplyURI(uri)
Output:

mongodb://127.0.0.1:27017/

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Handler to use; one of `pg` or `tigris` (if enabled at compile-time).
	Handler string

	// PostgreSQL connection string for `pg` handler.
	PostgreSQLURL string

	// Tigris connection string for `tigris` handler.
	TigrisURL string
}

Config represents FerretDB configuration.

type FerretDB

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

FerretDB represents an instance of embeddable FerretDB implementation.

func New

func New(config *Config) (*FerretDB, error)

New creates a new instance of embeddable FerretDB implementation.

func (*FerretDB) MongoDBURI

func (f *FerretDB) MongoDBURI() string

MongoDBURI returns MongoDB URI for this FerretDB instance.

func (*FerretDB) Run

func (f *FerretDB) Run(ctx context.Context) error

Run runs FerretDB until ctx is done.

When this method returns, listener and all connections are closed.

Source Files

Jump to

Keyboard shortcuts

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