Documentation ¶
Index ¶
- Constants
- type MongoBackend
- type MongoBackendConfig
- type MongoConnectConfig
- type MongoMasterInfo
- type RWLocker
- type SmartCollection
- func (s *SmartCollection) Collection() *mgo.Collection
- func (s *SmartCollection) EnsureIndexes(idxs []*mgo.Index) error
- func (s *SmartCollection) StartMongoDatastoreSegment(txn newrelic.Transaction, op string, query map[string]interface{}) *newrelic.DatastoreSegment
- func (s *SmartCollection) UpsertIndex(idx *mgo.Index) error
Constants ¶
View Source
const ( DefaultCollectionName = "masterlock" DefaultHeartbeatFrequency = time.Second * 5 MgoSessionRefreshFreq = time.Minute * 5 DefaultPoolLimit = 4 )
View Source
const MasterInfoID = "there-is-only-one-of-these"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoBackend ¶
type MongoBackend struct {
// contains filtered or unexported fields
}
func New ¶
func New(cfg *MongoBackendConfig) *MongoBackend
func (*MongoBackend) Connect ¶
func (m *MongoBackend) Connect() error
func (*MongoBackend) Lock ¶
func (m *MongoBackend) Lock(info *backend.MasterInfo) error
Achieve a lock to become the master. If lock is successful, the provided MasterInfo will be filled out and recorded. The MasterInfo passed in will be filled out with the remaining details.
func (*MongoBackend) Status ¶
func (m *MongoBackend) Status() (*backend.MasterInfo, error)
Get the current master status. Provides the MasterInfo of the current master.
func (*MongoBackend) UnLock ¶
func (m *MongoBackend) UnLock(masterID string) error
Release the lock to relinquish the master role. This will not succeed if the provided masterID does not match the ID of the current master.
func (*MongoBackend) WriteHeartbeat ¶
func (m *MongoBackend) WriteHeartbeat(info *backend.MasterInfo) error
Write a heartbeat to ensure that the master role is not lost. If successful, the last heartbeat time is written to the passed MasterInfo
type MongoBackendConfig ¶
type MongoBackendConfig struct { // Optional: What collection will the lock be stored in (default: "masterlock") CollectionName string // Required: Mongo connection config ConnectConfig *MongoConnectConfig // Optional: Frequency of master heartbeat write HeartBeatFreq time.Duration // Optional: Logger for the mongo backend to use (default: new logrus shim will be created) Logger log.Logger }
type MongoConnectConfig ¶
type MongoMasterInfo ¶
type SmartCollection ¶
type SmartCollection struct {
// contains filtered or unexported fields
}
func (*SmartCollection) Collection ¶
func (s *SmartCollection) Collection() *mgo.Collection
func (*SmartCollection) EnsureIndexes ¶
func (s *SmartCollection) EnsureIndexes(idxs []*mgo.Index) error
func (*SmartCollection) StartMongoDatastoreSegment ¶
func (s *SmartCollection) StartMongoDatastoreSegment(txn newrelic.Transaction, op string, query map[string]interface{}) *newrelic.DatastoreSegment
func (*SmartCollection) UpsertIndex ¶
func (s *SmartCollection) UpsertIndex(idx *mgo.Index) error
Ensure new index. If index already exists with same options, remove it and add new one.
Click to show internal directories.
Click to hide internal directories.