mongodb

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	URI      string `envconfig:"URI" env:"URI" default:"mongodb://localhost:27017"`
	Database string `envconfig:"DATABASE" env:"DATABASE" default:"authorization"`
	// contains filtered or unexported fields
}

type Option

type Option func(Config) Config

Option provides the means to use function call chaining

func WithTLS

func WithTLS(cfg *tls.Config) Option

WithTLS configures connection to use TLS

type PersistenceTx

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

PersistenceTx prevents data race for a sequence of read and write operations.

func (*PersistenceTx) Close

func (p *PersistenceTx) Close()

Close must always be called (use defer immediately after NewTransaction).

func (*PersistenceTx) Delete

func (p *PersistenceTx) Delete(deviceID, userID string) error

Delete removes the device's authorization record.

func (*PersistenceTx) Persist

Persist device's authorization details.

func (*PersistenceTx) Retrieve

func (p *PersistenceTx) Retrieve(deviceID, userID string) (_ *persistence.AuthorizedDevice, ok bool, err error)

Retrieve device's authorization details.

func (*PersistenceTx) RetrieveAll

func (p *PersistenceTx) RetrieveAll(userID string) persistence.Iterator

RetrieveAll retrieves all user's authorized devices.

func (*PersistenceTx) RetrieveByDevice

func (p *PersistenceTx) RetrieveByDevice(deviceID string) (_ *persistence.AuthorizedDevice, ok bool, err error)

RetrieveByDevice device's authorization details.

type Store

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

Store implements an Store for MongoDB.

func NewStore

func NewStore(ctx context.Context, cfg Config, opts ...Option) (*Store, error)

NewStore creates a new Store.

func NewStoreWithSession

func NewStoreWithSession(ctx context.Context, client *mongo.Client, dbPrefix string) (*Store, error)

NewStoreWithSession creates a new Store with a session.

func (*Store) Clear

func (s *Store) Clear(ctx context.Context) error

Clear clears the event storage.

func (*Store) Close

func (s *Store) Close(ctx context.Context) error

Close closes the database session.

func (*Store) DBName

func (s *Store) DBName() string

DBName returns db name

func (*Store) NewTransaction

func (p *Store) NewTransaction(ctx context.Context) persistence.PersistenceTx

NewTransaction creates a new transaction. A transaction must always be closed:

tx := s.persistence.NewTransaction()
defer tx.Close()

Jump to

Keyboard shortcuts

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