store

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: AGPL-3.0 Imports: 21 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MaxMigrateVersion added in v0.1.0

func MaxMigrateVersion() (uint, error)

MaxMigrateVersion returns the current DB migration file version

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func NewMigrateDSN added in v0.1.0

func NewMigrateDSN(dsn string) (*migrate.Migrate, error)

NewMigrateDSN returns a new Migrate instance from a database URL

func NewMigrateInstance added in v0.1.0

func NewMigrateInstance(db *sql.DB) (*migrate.Migrate, error)

NewMigrateInstance returns a new Migrate instance from a postgres instance

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type CommentOperator

type CommentOperator interface {
	// Save persists Comment in a store
	Save(context.Context, lookout.Event, *lookout.Comment, string) error
	// Posted checks if a comment was already posted for review
	Posted(context.Context, lookout.Event, *lookout.Comment) (bool, error)
}

CommentOperator manages persistence of Comments

type DBCommentOperator

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

DBCommentOperator operates on comments database store

func NewDBCommentOperator

NewDBCommentOperator creates new DBCommentOperator using kallax as storage

func (*DBCommentOperator) Posted

Posted implements EventOperator interface

func (*DBCommentOperator) Save

func (o *DBCommentOperator) Save(ctx context.Context, e lookout.Event, c *lookout.Comment, analyzerName string) error

Save implements EventOperator interface

type DBEventOperator

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

DBEventOperator operates on event database store

func NewDBEventOperator

NewDBEventOperator creates new DBEventOperator using kallax as storage

func (*DBEventOperator) Save

Save implements EventOperator interface

func (*DBEventOperator) UpdateStatus

func (o *DBEventOperator) UpdateStatus(ctx context.Context, e lookout.Event, status models.EventStatus) error

UpdateStatus implements EventOperator interface

type EventOperator

type EventOperator interface {
	// Save persists Event in a store and returns Status if event was persisted already
	Save(context.Context, lookout.Event) (models.EventStatus, error)
	// UpdateStatus updates Status of event in a store
	UpdateStatus(context.Context, lookout.Event, models.EventStatus) error
}

EventOperator manages persistence of Events

type MemCommentOperator

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

MemCommentOperator satisfies CommentOperator interface but does nothing

func NewMemCommentOperator

func NewMemCommentOperator() *MemCommentOperator

NewMemCommentOperator creates new MemCommentOperator

func (*MemCommentOperator) Posted

Posted implements EventOperator interface

func (*MemCommentOperator) Save

func (o *MemCommentOperator) Save(ctx context.Context, e lookout.Event, c *lookout.Comment, analyzerName string) error

Save implements EventOperator interface

type MemEventOperator

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

MemEventOperator satisfies EventOperator interface keeps events in memory

func NewMemEventOperator

func NewMemEventOperator() *MemEventOperator

NewMemEventOperator creates new MemEventOperator

func (*MemEventOperator) Save

Save implements EventOperator interface

func (*MemEventOperator) UpdateStatus

func (o *MemEventOperator) UpdateStatus(ctx context.Context, e lookout.Event, s models.EventStatus) error

UpdateStatus implements EventOperator interface

type NoopCommentOperator

type NoopCommentOperator struct{}

NoopCommentOperator satisfies CommentOperator interface but does nothing

func (*NoopCommentOperator) Posted

Posted implements EventOperator interface and always returns false

func (*NoopCommentOperator) Save

Save implements EventOperator interface and does nothing

type NoopEventOperator

type NoopEventOperator struct{}

NoopEventOperator satisfies EventOperator interface but does nothing

func (*NoopEventOperator) Save

Save implements EventOperator interface and always returns New status

func (*NoopEventOperator) UpdateStatus

UpdateStatus implements EventOperator interface and does nothing

Directories

Path Synopsis
Code generated by https://github.com/src-d/go-kallax.
Code generated by https://github.com/src-d/go-kallax.

Jump to

Keyboard shortcuts

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