📅  最后修改于: 2022-03-11 14:58:23.458000             🧑  作者: Mango
// omitting the other imports just to have a smaller code block
import com.mongodb.client.MongoClient
/**
* Configures Mongo as the Storage Engine.
*/
@Bean
fun storageEngine(client: MongoClient) = MongoEventStorageEngine.builder()
.mongoTemplate(
DefaultMongoTemplate.builder()
.mongoDatabase(client)
.build()
)
.build()
/**
* Configures to use Mongo embedded event store.
*/
@Bean
fun eventStore(storageEngine: EventStorageEngine) = EmbeddedEventStore.builder().storageEngine(storageEngine).build()
/**
* Configures to use in-memory token store.
*/
@Bean
fun tokenStore(client: MongoClient, serializer: Serializer) = MongoTokenStore.builder()
.mongoTemplate(
DefaultMongoTemplate.builder()
.mongoDatabase(client)
.build()
)
.serializer(serializer)
.build()