mongo

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package mongo implements Mserv MongoDB storage.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyUID is returned when middleware UID is empty.
	ErrEmptyUID = errors.New("UID cannot be empty")

	// ErrNotFound is returned when middleware is not found.
	ErrNotFound = errors.New("middleware not found")
)
View Source
var GetConf = func() *Config {
	if sconf == nil {
		sconf = &Config{}

		err := json.Unmarshal(conf.ReadConf(), sconf)
		if err != nil {
			log.Fatal("Failed to unmarshal mongo driver config: ", err)
		}
	}

	return sconf
}

Functions

This section is empty.

Types

type Config

type Config struct {
	MongoStore map[string]*MgoStoreConf
}

type MgoStoreConf

type MgoStoreConf struct {
	ConnStr string
}

type Store

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

func (*Store) CreateMW

func (m *Store) CreateMW(ctx context.Context, mw *storage.MW) (string, error)

CreateMW stores the given middleware.

func (*Store) DeleteMW

func (m *Store) DeleteMW(ctx context.Context, id string) error

DeleteMW removes given middleware.

func (*Store) GetAllActive

func (m *Store) GetAllActive(ctx context.Context) ([]*storage.MW, error)

GetAllActive returns all active middleware from the store.

func (*Store) GetMWByAPIID

func (m *Store) GetMWByAPIID(ctx context.Context, apiID string) (*storage.MW, error)

GetMWByAPIID gets middleware from the store based on its API ID.

func (*Store) GetMWByID

func (m *Store) GetMWByID(ctx context.Context, id string) (*storage.MW, error)

GetMWByID gets middleware from the store based on its UID.

func (*Store) GetTag

func (m *Store) GetTag() string

func (*Store) Health

func (m *Store) Health() map[string]interface{}

func (*Store) Init

func (m *Store) Init() error

func (*Store) InitMservStore

func (m *Store) InitMservStore(_ context.Context, tag string) error

InitMservStore initializes Mserv storage.

func (*Store) SetTag

func (m *Store) SetTag(tag string)

func (*Store) UpdateMW

func (m *Store) UpdateMW(ctx context.Context, mw *storage.MW) (string, error)

UpdateMW will update the given middleware in-place in storage.

Jump to

Keyboard shortcuts

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