db

package
v0.0.0-...-ec8dcbf Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DocAlreadyExisted = "document already existed"

DocAlreadyExisted means document already existed in the database when a new creation is requested

View Source
var DocNotFound = "no document found"

DocNotFound means no document found in the database

Functions

This section is empty.

Types

type Crud

type Crud interface {
	GetByTopic(topicFullName, pulsarURL string) (*model.FunctionConfig, error)
	GetByKey(hashedTopicKey string) (*model.FunctionConfig, error)
	Update(topicCfg *model.FunctionConfig) (string, error)
	Create(topicCfg *model.FunctionConfig) (string, error)
	Delete(topicFullName, pulsarURL string) (string, error)
	DeleteByKey(hashedTopicKey string) (string, error)

	// Load is invoked by the webhook.go to start new wekbooks and stop deleted ones
	Load() ([]*model.FunctionConfig, error)
}

Crud interface specifies typical CRUD opertaions for database

type Db

type Db interface {
	Crud
	Ops
}

Db interface embeds two other database interfaces

func NewDb

func NewDb(reqDbType string) (Db, error)

NewDb is a database factory pattern to create a new database

func NewDbWithPanic

func NewDbWithPanic(reqDbType string) Db

NewDbWithPanic ensures a database is returned panic otherwise

type InMemoryHandler

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

InMemoryHandler is the in memory cache driver

func NewInMemoryHandler

func NewInMemoryHandler() (*InMemoryHandler, error)

NewInMemoryHandler initialize a Mongo Db

func (*InMemoryHandler) Close

func (s *InMemoryHandler) Close() error

Close closes database

func (*InMemoryHandler) Create

func (s *InMemoryHandler) Create(functionCfg *model.FunctionConfig) (string, error)

Create creates a new document

func (*InMemoryHandler) Delete

func (s *InMemoryHandler) Delete(tenant, functionName string) (string, error)

Delete deletes a document

func (*InMemoryHandler) DeleteByKey

func (s *InMemoryHandler) DeleteByKey(hashedTopicKey string) (string, error)

DeleteByKey deletes a document based on key

func (*InMemoryHandler) GetByKey

func (s *InMemoryHandler) GetByKey(hashedTopicKey string) (*model.FunctionConfig, error)

GetByKey gets a document by the key

func (*InMemoryHandler) GetByTopic

func (s *InMemoryHandler) GetByTopic(tenant, functionName string) (*model.FunctionConfig, error)

GetByTopic gets a document by the topic name and pulsar URL

func (*InMemoryHandler) Health

func (s *InMemoryHandler) Health() bool

Health is a Db interface method

func (*InMemoryHandler) Init

func (s *InMemoryHandler) Init() error

Init is a Db interface method.

func (*InMemoryHandler) Load

func (s *InMemoryHandler) Load() ([]*model.FunctionConfig, error)

Load loads the entire database as a list

func (*InMemoryHandler) Sync

func (s *InMemoryHandler) Sync() error

Sync is a Db interface method.

func (*InMemoryHandler) Update

func (s *InMemoryHandler) Update(functionCfg *model.FunctionConfig) (string, error)

Update updates or creates a topic config document

type Ops

type Ops interface {
	Init() error
	Sync() error
	Close() error
	Health() bool
}

Ops interface specifies required database access operations

type PulsarHandler

type PulsarHandler struct {
	PulsarURL   string
	PulsarToken string
	TopicName   string
	// contains filtered or unexported fields
}

PulsarHandler is the Pulsar database driver

func NewPulsarHandler

func NewPulsarHandler() (*PulsarHandler, error)

NewPulsarHandler initialize a Pulsar Db

func (*PulsarHandler) Close

func (s *PulsarHandler) Close() error

Close closes database

func (*PulsarHandler) Create

func (s *PulsarHandler) Create(functionCfg *model.FunctionConfig) (string, error)

Create creates a new document

func (*PulsarHandler) Delete

func (s *PulsarHandler) Delete(tenant, functionName string) (string, error)

Delete deletes a document

func (*PulsarHandler) DeleteByKey

func (s *PulsarHandler) DeleteByKey(hashedTopicKey string) (string, error)

DeleteByKey deletes a document based on key

func (*PulsarHandler) GetByKey

func (s *PulsarHandler) GetByKey(hashedTopicKey string) (*model.FunctionConfig, error)

GetByKey gets a document by the key

func (*PulsarHandler) GetByTopic

func (s *PulsarHandler) GetByTopic(tenant, functionName string) (*model.FunctionConfig, error)

GetByTopic gets a document by the topic name and pulsar URL

func (*PulsarHandler) Health

func (s *PulsarHandler) Health() bool

Health is a Db interface method

func (*PulsarHandler) Init

func (s *PulsarHandler) Init() error

Init is a Db interface method.

func (*PulsarHandler) Load

func (s *PulsarHandler) Load() ([]*model.FunctionConfig, error)

Load loads the entire database into memory

func (*PulsarHandler) Sync

func (s *PulsarHandler) Sync() error

Sync is a Db interface method.

func (*PulsarHandler) Update

func (s *PulsarHandler) Update(functionCfg *model.FunctionConfig) (string, error)

Update updates or creates a topic config document

Jump to

Keyboard shortcuts

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