Package me.ahoo.cosid.spring.autoconfigure
package me.ahoo.cosid.spring.autoconfigure
-
ClassDescriptionThe
cosidendpoint and health indicator, each when its Actuator module is present.Starts theCosIdRuntime(07-runtime-and-spring.md §4.2): the spec fromcosid.*and theRuntimeSpecCustomizers (CosIdGeneratorRegistrar), theStoreProviderbeans, the clients of the context (DataSource, Lettuce orRedisConnectionFactory,MongoClient,CuratorFramework), theGeneratorListenerbeans and aHostResolverbean if any (Spring Cloud'sInetUtilsgives one, the first non-loopback address, as in 4.x).The read-onlycosidActuator endpoint (07 §4.2, D17), replacing the 4.xcosid,cosidGeneratorandcosidStringGeneratorendpoints:GET /actuator/cosid: every generator (CosIdRuntime.describe());GET /actuator/cosid/{name}: one generator;GET /actuator/cosid/{name}/long: alongid (snowflake,segmentandcustom);GET /actuator/cosid/{name}/string: a text id, through the generator's codec. An unknown generator answers 404; a disabled one, orlongof a text-only one, 400.The JSON body of a generator:GeneratorInfo, which has no bean accessors for Jackson, as a record.Registers one bean per generator, named after it, whose instanceCosIdRuntimeprovides (07 §4.1): the runtime stays the one source of truth.The bean of one generator: the runtime's view of it by the bean type, which counts the ids whencosid.metrics.generated.enabledis on.The health of the machine slots (07 §4.2, api-freeze.md §2.4), replacing the 4.xMachineIdHealthIndicator:DOWNwhen a started machine lost its lease and did not acquire it again, or when the slot binding of a time-based generator on it is no longer valid; otherwiseUP.The integrations (07-runtime-and-spring.md §5, D29), each when its module (cosid-jackson,cosid-mybatis,cosid-spring-data-jdbc,cosid-activiti,cosid-flowable,cosid-axon) and the classes it plugs into are on the classpath: Jackson: aCosIdJacksonModuleof the runtime, so@AsString(generator = ...)works. MyBatis (cosid.mybatis.enabled, default on): theCosIdInterceptor, batch inserts undercosid.mybatis.list-key(defaultlist). Spring Data JDBC (cosid.jdbc.enabled, off by default as in 4.x): theCosIdBeforeConvertCallback,@Idproperties fromcosid.jdbc.id-generator(defaultdefault). Activiti and Flowable (cosid.activiti.enabled,cosid.flowable.enabled, default on): the engine's id generator oncosid.activiti.generator-name/cosid.flowable.generator-name, else the system propertycosid.activiti/cosid.flowable, elsedefault. Axon: binds the runtime toCosIdIdentifierFactoryonce it is started and unbinds it before it is closed, generatorcosid.axon.generator-name, else the system propertycosid.axon, elsedefault.The Micrometer metrics (07 §2, 11 §5): aGeneratorListenerfor events and gauges on the runtime's state, replacing the 4.xCosIdMeterBinder.The Micrometer metrics (CosIdMeterListener) when the context has aMeterRegistry.Thecosid.*configuration (07-runtime-and-spring.md §4.1), bound once and immutable.An item of a codec list: exactly one of its fields.A date prefix.A friendly codec.Counting the ids every generator issues (cosid.generator.generated), through every view the runtime hands out (4.xcosid.metrics.generated.enabled).A generator.A slot leased from a store.The default machine slot: exactly one ofleasedorstatic.The Micrometer metrics.A named machine slot (D37,cosid.machines.<name>): exactly one ofleasedorstatic, in a namespace of its own.The period key of a periodic segment in its text ids (the 4.xgroup-prefix).A radix codec.What a time-based generator does when the clock goes back.A slot the deployment keeps unique.A store.Native image hints (11 §5): the stores'ServiceLoaderregistrations and providers, the Redis Lua scripts, the JDBC schemas and dialect registrations, the generator bean factory, and the endpoint'sCosIdEndpoint.Generatorfor JSON, and theCosIdPropertiesrecords the registrar binds.CosIdPropertiestoRuntimeSpec(07-runtime-and-spring.md §4.1):CosIdSpecs.toSpec(me.ahoo.cosid.spring.autoconfigure.CosIdProperties, java.time.ZoneId)is a pure function, no Spring involved;CosIdSpecs.bind(java.lang.Iterable<org.springframework.boot.context.properties.source.ConfigurationPropertySource>, org.springframework.boot.context.properties.bind.PlaceholdersResolver)bindscosid.*strictly.Changes theRuntimeSpecbuilt fromcosid.*before the runtime starts (07-runtime-and-spring.md §4.1): add, remove or change generators, stores or the machine.RedisScriptson a Spring DataRedisConnectionFactory(D6), for a factory without a native Lettuce client, such as a Jedis one; aLettuceConnectionFactory's own client is given to the store instead (clientOf(org.springframework.data.redis.connection.RedisConnectionFactory, me.ahoo.cosid.runtime.StoreSpec)), which opens a connection of its own on it.