Are you an LLM? You can read better optimized documentation at /guide/extensions/cosid-mongo.md for this page in Markdown format
CosId-Mongo Module
cosid-mongo provides support for MongoDB. Implements:
MachineIdDistributor: As the machine ID distributor for Snowflake algorithm (SnowflakeId).IdSegmentDistributor: As the segment distributor for segment algorithm (SegmentId).
Installation
kotlin
val cosidVersion = "latestVersion"
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
implementation("me.ahoo.cosid:cosid-mongo:${cosidVersion}")xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>me.ahoo.cosid</groupId>
<artifactId>cosid-mongo</artifactId>
<version>${cosid.version}</version>
</dependency>
</dependencies>Configuration Example
yaml
spring:
data:
mongodb:
uri: # Mongo distributor directly depends on spring-data-mongodb, which can omit additional configuration.
cosid:
namespace: ${spring.application.name}
machine:
enabled: true # Optional, needs to be set to true when using Snowflake algorithm
distributor:
type: mongo
segment:
enabled: true # Optional, needs to be set to true when using segment algorithm
distributor:
type: mongo