Package me.ahoo.cosid.store.mongo
Class MongoStore
java.lang.Object
me.ahoo.cosid.store.mongo.MongoStore
- All Implemented Interfaces:
AutoCloseable,me.ahoo.cosid.store.Store
The MongoDB store (06-stores.md ยง2.3):
MongoRangeStore and MongoSlotLeaseStore on one database,
MongoDB 6.0 or later. Every operation reads with majority concern on the primary, writes with the configured
write concern (majority by default, options.writeConcern) and runs under the driver's client-side
operation timeout (timeoutMS); an operation that runs out of it fails with
StoreTimeoutException.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe database whenoptions.databaseis not set. -
Constructor Summary
ConstructorsConstructorDescriptionMongoStore(com.mongodb.client.MongoDatabase database, Duration timeout) A store on a database whose client the caller owns and closes.MongoStore(com.mongodb.client.MongoDatabase database, Duration timeout, com.mongodb.WriteConcern writeConcern) A store on a database whose client the caller owns and closes, writing with the given concern. -
Method Summary
-
Field Details
-
DEFAULT_DATABASE
The database whenoptions.databaseis not set.- See Also:
-
-
Constructor Details
-
MongoStore
A store on a database whose client the caller owns and closes.- Parameters:
database- the databasetimeout- the operation timeout (timeoutMS); zero means none
-
MongoStore
public MongoStore(com.mongodb.client.MongoDatabase database, Duration timeout, com.mongodb.WriteConcern writeConcern) A store on a database whose client the caller owns and closes, writing with the given concern.- Parameters:
database- the databasetimeout- the operation timeout (timeoutMS); zero means nonewriteConcern- the write concern, acknowledged; anything weaker thanmajoritycan lose acknowledged writes on a failover and so hand out duplicate ids
-
-
Method Details
-
ranges
public me.ahoo.cosid.segment.RangeStore ranges()- Specified by:
rangesin interfaceme.ahoo.cosid.store.Store
-
slots
public me.ahoo.cosid.lease.SlotLeaseStore slots()- Specified by:
slotsin interfaceme.ahoo.cosid.store.Store
-
close
public void close()Closes the client the store created itself; an injected one stays open.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceme.ahoo.cosid.store.Store
-