Documentation ¶
Overview ¶
Package mock contains mocked implementations of the interfaces defined in the anser package.
These implementations expose all internals and do not have external dependencies. Indeed they should have interface-definition-only dependencies on other anser packages.
Index ¶
- type Client
- type Collection
- func (c *Collection) Aggregate(ctx context.Context, pipe interface{}, opts ...*options.AggregateOptions) (client.Cursor, error)
- func (c *Collection) Find(ctx context.Context, query interface{}, opts ...*options.FindOptions) (client.Cursor, error)
- func (c *Collection) FindOne(ctx context.Context, query interface{}, opts ...*options.FindOneOptions) client.SingleResult
- func (c *Collection) InsertMany(ctx context.Context, docs []interface{}) (*client.InsertManyResult, error)
- func (c *Collection) InsertOne(ctx context.Context, doc interface{}) (*client.InsertOneResult, error)
- func (c *Collection) Name() string
- func (c *Collection) ReplaceOne(ctx context.Context, query, update interface{}, ...) (*client.UpdateResult, error)
- func (c *Collection) UpdateMany(ctx context.Context, query, update interface{}, opts ...*options.UpdateOptions) (*client.UpdateResult, error)
- func (c *Collection) UpdateOne(ctx context.Context, query, update interface{}, opts ...*options.UpdateOptions) (*client.UpdateResult, error)
- type Cursor
- type Database
- func (d *Database) Client() client.Client
- func (d *Database) Collection(name string) client.Collection
- func (d *Database) Name() string
- func (d *Database) RunCommand(ctx context.Context, cmd interface{}) client.SingleResult
- func (d *Database) RunCommandCursor(ctx context.Context, cmd interface{}) (client.Cursor, error)
- type DependencyManager
- type DependencyNetwork
- func (n *DependencyNetwork) Add(name string, deps []string)
- func (n *DependencyNetwork) AddGroup(name string, group []string)
- func (n *DependencyNetwork) All() []string
- func (n *DependencyNetwork) GetGroup(name string) []string
- func (n *DependencyNetwork) MarshalJSON() ([]byte, error)
- func (n *DependencyNetwork) Network() map[string][]string
- func (n *DependencyNetwork) Resolve(name string) []string
- func (n *DependencyNetwork) String() string
- func (n *DependencyNetwork) Validate() error
- type Environment
- func (e *Environment) Close() error
- func (e *Environment) GetClient() (client.Client, error)
- func (e *Environment) GetDependencyNetwork() (model.DependencyNetworker, error)
- func (e *Environment) GetDocumentProcessor(name string) (client.Processor, bool)
- func (e *Environment) GetManualMigrationOperation(name string) (client.MigrationOperation, bool)
- func (e *Environment) GetQueue() (amboy.Queue, error)
- func (e *Environment) MetadataNamespace() model.Namespace
- func (e *Environment) NewDependencyManager(n string) dependency.Manager
- func (e *Environment) RegisterCloser(closer func() error)
- func (e *Environment) RegisterDocumentProcessor(name string, docp client.Processor) error
- func (e *Environment) RegisterManualMigrationOperation(name string, op client.MigrationOperation) error
- func (e *Environment) Setup(q amboy.Queue, cl client.Client, name string) error
- type Iterator
- type LegacyCollection
- func (c *LegacyCollection) Bulk() db.Bulk
- func (c *LegacyCollection) Count() (int, error)
- func (c *LegacyCollection) DropCollection() error
- func (c *LegacyCollection) Find(q interface{}) db.Query
- func (c *LegacyCollection) FindId(q interface{}) db.Query
- func (c *LegacyCollection) Insert(docs ...interface{}) error
- func (c *LegacyCollection) Pipe(p interface{}) db.Results
- func (c *LegacyCollection) Remove(q interface{}) error
- func (c *LegacyCollection) RemoveAll(q interface{}) (*db.ChangeInfo, error)
- func (c *LegacyCollection) RemoveId(id interface{}) error
- func (c *LegacyCollection) Update(q, u interface{}) error
- func (c *LegacyCollection) UpdateAll(q, u interface{}) (*db.ChangeInfo, error)
- func (c *LegacyCollection) UpdateId(id, u interface{}) error
- func (c *LegacyCollection) Upsert(q, u interface{}) (*db.ChangeInfo, error)
- func (c *LegacyCollection) UpsertId(id, u interface{}) (*db.ChangeInfo, error)
- type LegacyDatabase
- type LegacyProcessor
- type MigrationHelper
- func (m *MigrationHelper) Env() Environment
- func (m *MigrationHelper) FinishMigration(name string, j *job.Base)
- func (m *MigrationHelper) GetMigrationEvents(_ map[string]interface{}) (db.Iterator, error)
- func (m *MigrationHelper) PendingMigrationOperations(_ model.Namespace, _ map[string]interface{}) int
- func (m *MigrationHelper) SaveMigrationEvent(data *model.MigrationMetadata) error
- type Pipeline
- type Processor
- type Query
- func (q *Query) All(r interface{}) error
- func (q *Query) Apply(ch db.Change, r interface{}) (*db.ChangeInfo, error)
- func (q *Query) Count() (int, error)
- func (q *Query) Iter() db.Iterator
- func (q *Query) Limit(n int) db.Query
- func (q *Query) One(r interface{}) error
- func (q *Query) Select(p interface{}) db.Query
- func (q *Query) Skip(n int) db.Query
- func (q *Query) Sort(keys ...string) db.Query
- type Session
- type SingleResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct { CollName string Cursor *Cursor SingleResult *SingleResult UpdateResult client.UpdateResult InsertManyResult client.InsertManyResult InsertOneResult client.InsertOneResult FindError error AggregateError error }
func (*Collection) Aggregate ¶
func (c *Collection) Aggregate(ctx context.Context, pipe interface{}, opts ...*options.AggregateOptions) (client.Cursor, error)
func (*Collection) Find ¶
func (c *Collection) Find(ctx context.Context, query interface{}, opts ...*options.FindOptions) (client.Cursor, error)
func (*Collection) FindOne ¶
func (c *Collection) FindOne(ctx context.Context, query interface{}, opts ...*options.FindOneOptions) client.SingleResult
func (*Collection) InsertMany ¶
func (c *Collection) InsertMany(ctx context.Context, docs []interface{}) (*client.InsertManyResult, error)
func (*Collection) InsertOne ¶
func (c *Collection) InsertOne(ctx context.Context, doc interface{}) (*client.InsertOneResult, error)
func (*Collection) Name ¶
func (c *Collection) Name() string
func (*Collection) ReplaceOne ¶
func (c *Collection) ReplaceOne(ctx context.Context, query, update interface{}, opts ...*options.ReplaceOptions) (*client.UpdateResult, error)
func (*Collection) UpdateMany ¶
func (c *Collection) UpdateMany(ctx context.Context, query, update interface{}, opts ...*options.UpdateOptions) (*client.UpdateResult, error)
func (*Collection) UpdateOne ¶
func (c *Collection) UpdateOne(ctx context.Context, query, update interface{}, opts ...*options.UpdateOptions) (*client.UpdateResult, error)
type Cursor ¶
type Database ¶
type Database struct { DBName string Collections map[string]*Collection }
func (*Database) Collection ¶
func (d *Database) Collection(name string) client.Collection
func (*Database) RunCommand ¶
func (d *Database) RunCommand(ctx context.Context, cmd interface{}) client.SingleResult
type DependencyManager ¶
type DependencyManager struct { Name string Query map[string]interface{} StateValue dependency.State T dependency.TypeInfo *dependency.JobEdges }
func (*DependencyManager) State ¶
func (d *DependencyManager) State() dependency.State
func (*DependencyManager) Type ¶
func (d *DependencyManager) Type() dependency.TypeInfo
type DependencyNetwork ¶
type DependencyNetwork struct { Graph map[string][]string Groups map[string][]string ValidateError error }
DependencyNetwork provides a mock implementation of the anser.DependencyNetworker interface. This implementation, unlike the default one, does no deduplicate the dependency.
func NewDependencyNetwork ¶
func NewDependencyNetwork() *DependencyNetwork
func (*DependencyNetwork) Add ¶
func (n *DependencyNetwork) Add(name string, deps []string)
func (*DependencyNetwork) AddGroup ¶
func (n *DependencyNetwork) AddGroup(name string, group []string)
func (*DependencyNetwork) All ¶
func (n *DependencyNetwork) All() []string
func (*DependencyNetwork) GetGroup ¶
func (n *DependencyNetwork) GetGroup(name string) []string
func (*DependencyNetwork) MarshalJSON ¶
func (n *DependencyNetwork) MarshalJSON() ([]byte, error)
func (*DependencyNetwork) Network ¶
func (n *DependencyNetwork) Network() map[string][]string
func (*DependencyNetwork) Resolve ¶
func (n *DependencyNetwork) Resolve(name string) []string
func (*DependencyNetwork) String ¶
func (n *DependencyNetwork) String() string
func (*DependencyNetwork) Validate ¶
func (n *DependencyNetwork) Validate() error
type Environment ¶
type Environment struct { ShouldPreferClient bool IsSetup bool ReturnNilClient bool SetupError error ClientError error QueueError error NetworkError error PreferedSetup interface{} Client *Client Network *DependencyNetwork Queue amboy.Queue SetupClient client.Client Closers []func() error DependencyManagers map[string]*DependencyManager MigrationRegistry map[string]client.MigrationOperation ProcessorRegistry map[string]client.Processor MetaNS model.Namespace }
func NewEnvironment ¶
func NewEnvironment() *Environment
func (*Environment) Close ¶
func (e *Environment) Close() error
func (*Environment) GetDependencyNetwork ¶
func (e *Environment) GetDependencyNetwork() (model.DependencyNetworker, error)
func (*Environment) GetDocumentProcessor ¶
func (e *Environment) GetDocumentProcessor(name string) (client.Processor, bool)
func (*Environment) GetManualMigrationOperation ¶
func (e *Environment) GetManualMigrationOperation(name string) (client.MigrationOperation, bool)
func (*Environment) MetadataNamespace ¶
func (e *Environment) MetadataNamespace() model.Namespace
func (*Environment) NewDependencyManager ¶
func (e *Environment) NewDependencyManager(n string) dependency.Manager
func (*Environment) RegisterCloser ¶
func (e *Environment) RegisterCloser(closer func() error)
func (*Environment) RegisterDocumentProcessor ¶
func (e *Environment) RegisterDocumentProcessor(name string, docp client.Processor) error
func (*Environment) RegisterManualMigrationOperation ¶
func (e *Environment) RegisterManualMigrationOperation(name string, op client.MigrationOperation) error
type Iterator ¶
type LegacyCollection ¶
type LegacyCollection struct { Name string InsertedDocs []interface{} UpdatedIds []interface{} FailWrites bool Queries []*Query Pipelines []*Pipeline NumDocs int QueryError error Mutex sync.Mutex }
func (*LegacyCollection) Bulk ¶
func (c *LegacyCollection) Bulk() db.Bulk
func (*LegacyCollection) Count ¶
func (c *LegacyCollection) Count() (int, error)
func (*LegacyCollection) DropCollection ¶
func (c *LegacyCollection) DropCollection() error
func (*LegacyCollection) Find ¶
func (c *LegacyCollection) Find(q interface{}) db.Query
func (*LegacyCollection) FindId ¶
func (c *LegacyCollection) FindId(q interface{}) db.Query
func (*LegacyCollection) Insert ¶
func (c *LegacyCollection) Insert(docs ...interface{}) error
func (*LegacyCollection) Pipe ¶
func (c *LegacyCollection) Pipe(p interface{}) db.Results
func (*LegacyCollection) Remove ¶
func (c *LegacyCollection) Remove(q interface{}) error
func (*LegacyCollection) RemoveAll ¶
func (c *LegacyCollection) RemoveAll(q interface{}) (*db.ChangeInfo, error)
func (*LegacyCollection) RemoveId ¶
func (c *LegacyCollection) RemoveId(id interface{}) error
func (*LegacyCollection) Update ¶
func (c *LegacyCollection) Update(q, u interface{}) error
func (*LegacyCollection) UpdateAll ¶
func (c *LegacyCollection) UpdateAll(q, u interface{}) (*db.ChangeInfo, error)
func (*LegacyCollection) UpdateId ¶
func (c *LegacyCollection) UpdateId(id, u interface{}) error
func (*LegacyCollection) Upsert ¶
func (c *LegacyCollection) Upsert(q, u interface{}) (*db.ChangeInfo, error)
func (*LegacyCollection) UpsertId ¶
func (c *LegacyCollection) UpsertId(id, u interface{}) (*db.ChangeInfo, error)
type LegacyDatabase ¶
type LegacyDatabase struct { Collections map[string]*LegacyCollection DBName string Mutex sync.Mutex }
func (*LegacyDatabase) C ¶
func (d *LegacyDatabase) C(n string) db.Collection
func (*LegacyDatabase) DropDatabase ¶
func (d *LegacyDatabase) DropDatabase() error
func (*LegacyDatabase) Name ¶
func (d *LegacyDatabase) Name() string
type LegacyProcessor ¶
type LegacyProcessor struct { NS model.Namespace Query map[string]interface{} Iter *Iterator MigrateError error LastMigrateCallMismatch bool NumMigrateCalls int }
type MigrationHelper ¶
type MigrationHelper struct { Environment Environment MigrationEvents []*model.MigrationMetadata SaveMigrationEventError error NumPendingMigrations int GetMigrationEventsIter *Iterator GetMigrationEventsError error }
func (*MigrationHelper) Env ¶
func (m *MigrationHelper) Env() Environment
func (*MigrationHelper) FinishMigration ¶
func (m *MigrationHelper) FinishMigration(name string, j *job.Base)
func (*MigrationHelper) GetMigrationEvents ¶
func (m *MigrationHelper) GetMigrationEvents(_ map[string]interface{}) (db.Iterator, error)
func (*MigrationHelper) PendingMigrationOperations ¶
func (m *MigrationHelper) PendingMigrationOperations(_ model.Namespace, _ map[string]interface{}) int
func (*MigrationHelper) SaveMigrationEvent ¶
func (m *MigrationHelper) SaveMigrationEvent(data *model.MigrationMetadata) error
type Processor ¶
type Processor struct { NS model.Namespace Query map[string]interface{} Cursor client.Cursor MigrateError error LastMigrateCallMismatch bool NumMigrateCalls int }
type Query ¶
type Session ¶
type Session struct { DBs map[string]*LegacyDatabase URI string Closed bool SocketTimeout time.Duration Mutex sync.Mutex }
func NewSession ¶
func NewSession() *Session
func (*Session) SetSocketTimeout ¶
type SingleResult ¶
type SingleResult struct { DecodeError error DecodeBytesError error DecodeBytesValue []byte ErrorValue error }
func NewSingleResult ¶
func NewSingleResult() *SingleResult
func (*SingleResult) Decode ¶
func (sr *SingleResult) Decode(in interface{}) error
func (*SingleResult) DecodeBytes ¶
func (sr *SingleResult) DecodeBytes() ([]byte, error)
func (*SingleResult) Err ¶
func (sr *SingleResult) Err() error
Click to show internal directories.
Click to hide internal directories.