Documentation ¶
Index ¶
- Constants
- Variables
- type Bulk
- type Client
- type ClientOptionFunc
- func WithCACerts(certs []string) ClientOptionFunc
- func WithFsync(fsync bool) ClientOptionFunc
- func WithSSL(ssl bool) ClientOptionFunc
- func WithTail(tail bool) ClientOptionFunc
- func WithTimeout(timeout string) ClientOptionFunc
- func WithURI(uri string) ClientOptionFunc
- func WithWriteConcern(wc int) ClientOptionFunc
- type Config
- type MongoDB
- type OplogAccessError
- type Reader
- type Session
- type Tailer
- type Writer
Constants ¶
const ( // DefaultURI is the default endpoint of MongoDB on the local machine. // Primarily used when initializing a new Client without a specific URI. DefaultURI = "mongodb://127.0.0.1:27017/test" // DefaultSessionTimeout is the default timeout after which the // session times out when unable to connect to the provided URI. DefaultSessionTimeout = 10 * time.Second )
Variables ¶
var ( // DefaultSafety is the default saftey mode used for the underlying session. // These default settings are only good for local use as it makes not guarantees for writes. DefaultSafety = mgo.Safe{} )
Functions ¶
This section is empty.
Types ¶
type Bulk ¶
Bulk implements client.Writer for use with MongoDB and takes advantage of the Bulk API for performance improvements.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a client to the underlying MongoDB source.
func NewClient ¶
func NewClient(options ...ClientOptionFunc) (*Client, error)
NewClient creates a new client to work with MongoDB.
The caller can configure the new client by passing configuration options to the func.
Example:
client, err := NewClient( WithURI("mongodb://localhost:27017"), WithTimeout("30s"))
If no URI is configured, it uses defaultURI by default.
An error is also returned when some configuration option is invalid
type ClientOptionFunc ¶
ClientOptionFunc is a function that configures a Client. It is used in NewClient.
func WithCACerts ¶
func WithCACerts(certs []string) ClientOptionFunc
WithCACerts configures the RootCAs for the underlying TLS connection
func WithFsync ¶
func WithFsync(fsync bool) ClientOptionFunc
WithFsync configures whether the server will wait for Fsync to complete before returning a response (Default: false).
func WithSSL ¶
func WithSSL(ssl bool) ClientOptionFunc
WithSSL configures the database connection to connect via TLS.
func WithTail ¶
func WithTail(tail bool) ClientOptionFunc
WithTail set the flag to tell the Client whether or not access to the oplog will be needed (Default: false).
func WithTimeout ¶
func WithTimeout(timeout string) ClientOptionFunc
WithTimeout overrides the DefaultSessionTimeout and should be parseable by time.ParseDuration
func WithURI ¶
func WithURI(uri string) ClientOptionFunc
WithURI defines the full connection string of the MongoDB database.
func WithWriteConcern ¶
func WithWriteConcern(wc int) ClientOptionFunc
WithWriteConcern configures the write concern option for the session (Default: 0).
type Config ¶
type Config struct { URI string `json:"uri" doc:"the uri to connect to, in the form mongodb://user:password@host.com:27017/auth_database"` Namespace string `json:"namespace" doc:"mongo namespace to read/write"` SSL bool `json:"ssl" doc:"ssl options for connection"` CACerts []string `json:"cacerts" doc:"array of root CAs to use in order to verify the server certificates"` Timeout string `json:"timeout" doc:"timeout for establishing connection, format must be parsable by time.ParseDuration and defaults to 10s"` Tail bool `json:"tail" doc:"if tail is true, then the mongodb source will tail the oplog after copying the namespace"` Wc int `` /* 143-byte string literal not displayed */ FSync bool `json:"fsync" doc:"When writing, should we flush to disk before returning success"` Bulk bool `json:"bulk" doc:"use a buffer to bulk insert documents"` }
Config provides configuration options for a mongodb adaptor the notable difference between this and dbConfig is the presence of the Tail option
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
MongoDB is an adaptor to read / write to mongodb. it works as a source by copying files, and then optionally tailing the oplog
func (*MongoDB) Description ¶
Description for mongodb adaptor
func (*MongoDB) SampleConfig ¶
SampleConfig for mongodb adaptor
type OplogAccessError ¶
type OplogAccessError struct {
// contains filtered or unexported fields
}
OplogAccessError wraps the underlying error when access to the oplog fails.
func (OplogAccessError) Error ¶
func (e OplogAccessError) Error() string
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader implements the behavior defined by client.Reader for interfacing with MongoDB.
func (*Reader) Read ¶
func (r *Reader) Read(filterFn client.NsFilterFunc) client.MessageChanFunc
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session serves as a wrapper for the underlying mgo.Session
type Tailer ¶
type Tailer struct {
// contains filtered or unexported fields
}
Tailer implements the behavior defined by client.Reader for interfacing with the MongoDB oplog.
func (*Tailer) Read ¶
func (t *Tailer) Read(filterFn client.NsFilterFunc) client.MessageChanFunc
Tail does the things