@effect-app/infra 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/_cjs/{lib/RequestContext.cjs → RequestContext.cjs} +0 -0
- package/_cjs/{lib/RequestContext.cjs.map → RequestContext.cjs.map} +1 -1
- package/_cjs/{lib/api → api}/authorization.jwt.cjs +1 -1
- package/_cjs/{lib/api → api}/authorization.jwt.cjs.map +1 -1
- package/_cjs/{vendor/Cache/Cache/operations/makeWith.cjs → api/codec.cjs} +16 -13
- package/_cjs/api/codec.cjs.map +1 -0
- package/_cjs/{lib/api → api}/defaultErrorHandler.cjs +1 -1
- package/_cjs/{lib/api → api}/defaultErrorHandler.cjs.map +1 -1
- package/_cjs/{services/memQueue.cjs → api/express/makeJsonSchema.cjs} +42 -22
- package/_cjs/api/express/makeJsonSchema.cjs.map +1 -0
- package/_cjs/api/express/makeOpenApiSpecs.cjs +66 -0
- package/_cjs/api/express/makeOpenApiSpecs.cjs.map +1 -0
- package/_cjs/api/express/schema/jwt.cjs +43 -0
- package/_cjs/api/express/schema/jwt.cjs.map +1 -0
- package/_cjs/api/express/schema/requestHandler.cjs +166 -0
- package/_cjs/api/express/schema/requestHandler.cjs.map +1 -0
- package/_cjs/api/express/schema/routing.cjs +121 -0
- package/_cjs/api/express/schema/routing.cjs.map +1 -0
- package/_cjs/{lib/api → api}/reportError.cjs +5 -5
- package/_cjs/{lib/api → api}/reportError.cjs.map +1 -1
- package/_cjs/{lib/api → api}/routing.cjs +32 -32
- package/_cjs/{lib/api → api}/routing.cjs.map +1 -1
- package/_cjs/{lib/api → api}/setupRequest.cjs +2 -2
- package/_cjs/{lib/api → api}/setupRequest.cjs.map +1 -1
- package/_cjs/{lib/api → api}/util.cjs +0 -0
- package/_cjs/{lib/api → api}/util.cjs.map +1 -1
- package/_cjs/{lib/api → api}/writeDocs.cjs +5 -5
- package/_cjs/{lib/api → api}/writeDocs.cjs.map +1 -1
- package/_cjs/{lib/errorReporter.cjs → errorReporter.cjs} +1 -1
- package/_cjs/{lib/errorReporter.cjs.map → errorReporter.cjs.map} +1 -1
- package/_cjs/errors.cjs +21 -22
- package/_cjs/errors.cjs.map +1 -1
- package/_cjs/{lib/ext → ext}/Array.cjs +1 -1
- package/_cjs/{lib/ext → ext}/Array.cjs.map +1 -1
- package/_cjs/{lib/filter → filter}/types/errors.cjs +0 -0
- package/_cjs/{lib/filter → filter}/types/errors.cjs.map +0 -0
- package/_cjs/{lib/filter → filter}/types/fields.cjs +0 -0
- package/_cjs/{lib/filter → filter}/types/fields.cjs.map +0 -0
- package/_cjs/{lib/filter → filter}/types/index.cjs +0 -0
- package/_cjs/{lib/filter → filter}/types/index.cjs.map +1 -1
- package/_cjs/{lib/filter → filter}/types/path/common.cjs +0 -0
- package/_cjs/{lib/filter → filter}/types/path/common.cjs.map +0 -0
- package/_cjs/{lib/filter → filter}/types/path/eager.cjs +0 -0
- package/_cjs/{lib/filter → filter}/types/path/eager.cjs.map +0 -0
- package/_cjs/{lib/filter → filter}/types/path/index.cjs +0 -0
- package/_cjs/filter/types/path/index.cjs.map +1 -0
- package/_cjs/{lib/filter → filter}/types/utils.cjs +0 -0
- package/_cjs/{lib/filter → filter}/types/utils.cjs.map +0 -0
- package/_cjs/{lib/filter → filter}/types/validator.cjs +0 -0
- package/_cjs/{lib/filter → filter}/types/validator.cjs.map +0 -0
- package/_cjs/{lib/filter.cjs → filter.cjs} +0 -0
- package/_cjs/{lib/filter.cjs.map → filter.cjs.map} +1 -1
- package/_cjs/{lib/instrument.cjs → instrument.cjs} +1 -1
- package/_cjs/{lib/instrument.cjs.map → instrument.cjs.map} +1 -1
- package/_cjs/{lib/rateLimit.cjs → rateLimit.cjs} +1 -1
- package/_cjs/{lib/rateLimit.cjs.map → rateLimit.cjs.map} +1 -1
- package/_cjs/services/Emailer/Sendgrid.cjs +1 -1
- package/_cjs/services/Emailer/fake.cjs +1 -1
- package/_cjs/services/Repository.cjs +1 -1
- package/_cjs/services/Store/Cosmos.cjs +2 -2
- package/_cjs/services/Store/Cosmos.test.cjs +2 -2
- package/_cjs/services/Store/Disk.cjs +2 -2
- package/_cjs/services/Store/Memory.cjs +1 -1
- package/_cjs/services/Store/Redis.cjs +1 -1
- package/_cjs/services/Store/codeFilter.test.cjs +2 -2
- package/_cjs/services/Store/index.cjs +1 -1
- package/_cjs/services/Store/service.cjs +1 -1
- package/_cjs/services/Store/utils.cjs +1 -1
- package/_cjs/services/simpledb/cosmosdb.cjs +98 -0
- package/_cjs/services/simpledb/cosmosdb.cjs.map +1 -0
- package/_cjs/services/simpledb/diskdb.cjs +118 -0
- package/_cjs/services/simpledb/diskdb.cjs.map +1 -0
- package/_cjs/services/simpledb/fileutil.cjs +36 -0
- package/_cjs/services/simpledb/fileutil.cjs.map +1 -0
- package/_cjs/{vendor/Cache/Cache/_internal/CacheState.cjs → services/simpledb/index.cjs} +31 -24
- package/_cjs/services/simpledb/index.cjs.map +1 -0
- package/_cjs/services/simpledb/memdb.cjs +74 -0
- package/_cjs/services/simpledb/memdb.cjs.map +1 -0
- package/_cjs/services/simpledb/mongodb.cjs +86 -0
- package/_cjs/services/simpledb/mongodb.cjs.map +1 -0
- package/_cjs/services/simpledb/redisdb.cjs +120 -0
- package/_cjs/services/simpledb/redisdb.cjs.map +1 -0
- package/_cjs/services/simpledb/shared.cjs +80 -0
- package/_cjs/services/simpledb/shared.cjs.map +1 -0
- package/_cjs/services/simpledb/simpledb.cjs +77 -0
- package/_cjs/services/simpledb/simpledb.cjs.map +1 -0
- package/_src/{lib/RequestContext.ts → RequestContext.ts} +0 -0
- package/_src/_global.ext.ts +5 -5
- package/_src/api/app.ts.bak +125 -0
- package/_src/{lib/api → api}/authorization.jwt.ts +1 -1
- package/_src/api/codec.ts +27 -0
- package/_src/{lib/api → api}/defaultErrorHandler.ts +1 -1
- package/_src/api/errors.ts.bak +20 -0
- package/_src/api/express/makeJsonSchema.ts +49 -0
- package/_src/api/express/makeOpenApiSpecs.ts +60 -0
- package/_src/api/express/routing.ts.bak +460 -0
- package/_src/api/express/schema/jwt.ts +38 -0
- package/_src/api/express/schema/requestHandler.ts +360 -0
- package/_src/api/express/schema/routing.ts +202 -0
- package/_src/{lib/api → api}/reportError.ts +3 -3
- package/_src/{lib/api → api}/routing.ts +7 -12
- package/_src/{lib/api → api}/setupRequest.ts +0 -0
- package/_src/{lib/api → api}/util.ts +0 -0
- package/_src/{lib/api → api}/writeDocs.ts +4 -5
- package/_src/{lib/errorReporter.ts → errorReporter.ts} +1 -1
- package/_src/errors.ts +12 -3
- package/_src/{lib/ext → ext}/Array.ts +1 -1
- package/_src/{lib/filter → filter}/types/errors.ts +0 -0
- package/_src/{lib/filter → filter}/types/fields.ts +0 -0
- package/_src/{lib/filter → filter}/types/index.ts +0 -0
- package/_src/{lib/filter → filter}/types/path/common.ts +0 -0
- package/_src/{lib/filter → filter}/types/path/eager.ts +0 -0
- package/_src/{lib/filter → filter}/types/path/index.ts +0 -0
- package/_src/{lib/filter → filter}/types/utils.ts +0 -0
- package/_src/{lib/filter → filter}/types/validator.ts +0 -0
- package/_src/{lib/filter.ts → filter.ts} +1 -1
- package/_src/{lib/instrument.ts → instrument.ts} +0 -0
- package/_src/{lib/rateLimit.ts → rateLimit.ts} +0 -0
- package/_src/services/Emailer/service.ts +1 -1
- package/_src/services/Repository.ts +1 -1
- package/_src/services/Store/Cosmos.test.ts +1 -1
- package/_src/services/Store/Disk.ts +1 -1
- package/_src/services/Store/codeFilter.test.ts +1 -1
- package/_src/services/simpledb/cosmosdb.ts +134 -0
- package/_src/services/simpledb/diskdb.ts +158 -0
- package/_src/services/simpledb/fileutil.ts +28 -0
- package/_src/services/simpledb/index.ts +6 -0
- package/_src/services/simpledb/memdb.ts +79 -0
- package/_src/services/simpledb/mongodb.ts +99 -0
- package/_src/services/simpledb/redisdb.ts +182 -0
- package/_src/services/simpledb/shared.ts +117 -0
- package/_src/services/simpledb/simpledb.ts +117 -0
- package/dist/{lib/RequestContext.d.ts → RequestContext.d.ts} +1 -1
- package/dist/RequestContext.d.ts.map +1 -0
- package/dist/RequestContext.js +52 -0
- package/dist/_global.ext.d.ts +5 -5
- package/dist/_global.ext.d.ts.map +1 -1
- package/dist/{lib/api → api}/authorization.jwt.d.ts +1 -1
- package/dist/api/authorization.jwt.d.ts.map +1 -0
- package/dist/{lib/api → api}/authorization.jwt.js +2 -2
- package/dist/api/codec.d.ts +7 -0
- package/dist/api/codec.d.ts.map +1 -0
- package/dist/api/codec.js +19 -0
- package/dist/{lib/api → api}/defaultErrorHandler.d.ts +1 -1
- package/dist/api/defaultErrorHandler.d.ts.map +1 -0
- package/dist/{lib/api → api}/defaultErrorHandler.js +2 -2
- package/dist/api/express/makeJsonSchema.d.ts +30 -0
- package/dist/api/express/makeJsonSchema.d.ts.map +1 -0
- package/dist/api/express/makeJsonSchema.js +40 -0
- package/dist/api/express/makeOpenApiSpecs.d.ts +55 -0
- package/dist/api/express/makeOpenApiSpecs.d.ts.map +1 -0
- package/dist/api/express/makeOpenApiSpecs.js +56 -0
- package/dist/api/express/schema/jwt.d.ts +5 -0
- package/dist/api/express/schema/jwt.d.ts.map +1 -0
- package/dist/api/express/schema/jwt.js +32 -0
- package/dist/api/express/schema/requestHandler.d.ts +71 -0
- package/dist/api/express/schema/requestHandler.d.ts.map +1 -0
- package/dist/api/express/schema/requestHandler.js +140 -0
- package/dist/api/express/schema/routing.d.ts +45 -0
- package/dist/api/express/schema/routing.d.ts.map +1 -0
- package/dist/api/express/schema/routing.js +95 -0
- package/dist/{lib/api → api}/reportError.d.ts +4 -4
- package/dist/api/reportError.d.ts.map +1 -0
- package/dist/{lib/api → api}/reportError.js +6 -6
- package/dist/{lib/api → api}/routing.d.ts +7 -7
- package/dist/api/routing.d.ts.map +1 -0
- package/dist/api/routing.js +249 -0
- package/dist/{lib/api → api}/setupRequest.d.ts +2 -2
- package/dist/api/setupRequest.d.ts.map +1 -0
- package/dist/{lib/api → api}/setupRequest.js +3 -3
- package/dist/{lib/api → api}/util.d.ts +0 -0
- package/dist/api/util.d.ts.map +1 -0
- package/dist/api/util.js +14 -0
- package/dist/{lib/api → api}/writeDocs.d.ts +1 -1
- package/dist/api/writeDocs.d.ts.map +1 -0
- package/dist/api/writeDocs.js +23 -0
- package/dist/{lib/errorReporter.d.ts → errorReporter.d.ts} +1 -1
- package/dist/errorReporter.d.ts.map +1 -0
- package/dist/errorReporter.js +45 -0
- package/dist/errors.d.ts +11 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +17 -3
- package/dist/{lib/ext → ext}/Array.d.ts +3 -3
- package/dist/ext/Array.d.ts.map +1 -0
- package/dist/{lib/ext → ext}/Array.js +2 -2
- package/dist/{lib/filter → filter}/types/errors.d.ts +0 -0
- package/dist/filter/types/errors.d.ts.map +1 -0
- package/dist/{lib/filter → filter}/types/errors.js +1 -1
- package/dist/{lib/filter → filter}/types/fields.d.ts +0 -0
- package/dist/filter/types/fields.d.ts.map +1 -0
- package/dist/{lib/filter → filter}/types/fields.js +1 -1
- package/dist/{lib/filter → filter}/types/index.d.ts +0 -0
- package/dist/filter/types/index.d.ts.map +1 -0
- package/dist/{lib/filter → filter}/types/index.js +1 -1
- package/dist/{lib/filter → filter}/types/path/common.d.ts +0 -0
- package/dist/filter/types/path/common.d.ts.map +1 -0
- package/dist/{lib/filter → filter}/types/path/common.js +1 -1
- package/dist/{lib/filter → filter}/types/path/eager.d.ts +0 -0
- package/dist/filter/types/path/eager.d.ts.map +1 -0
- package/dist/{lib/filter → filter}/types/path/eager.js +1 -1
- package/dist/{lib/filter → filter}/types/path/index.d.ts +0 -0
- package/dist/filter/types/path/index.d.ts.map +1 -0
- package/dist/{lib/filter → filter}/types/path/index.js +1 -1
- package/dist/{lib/filter → filter}/types/utils.d.ts +0 -0
- package/dist/filter/types/utils.d.ts.map +1 -0
- package/dist/{lib/filter → filter}/types/utils.js +1 -1
- package/dist/{lib/filter → filter}/types/validator.d.ts +0 -0
- package/dist/filter/types/validator.d.ts.map +1 -0
- package/dist/{lib/filter → filter}/types/validator.js +1 -1
- package/dist/{lib/filter.d.ts → filter.d.ts} +9 -9
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.js +171 -0
- package/dist/{lib/instrument.d.ts → instrument.d.ts} +1 -1
- package/dist/instrument.d.ts.map +1 -0
- package/dist/{lib/instrument.js → instrument.js} +2 -2
- package/dist/{lib/rateLimit.d.ts → rateLimit.d.ts} +5 -5
- package/dist/rateLimit.d.ts.map +1 -0
- package/dist/{lib/rateLimit.js → rateLimit.js} +2 -2
- package/dist/services/Emailer/Sendgrid.js +1 -1
- package/dist/services/Emailer/fake.js +1 -1
- package/dist/services/Emailer/service.d.ts +1 -1
- package/dist/services/Emailer/service.d.ts.map +1 -1
- package/dist/services/Repository.d.ts +1 -1
- package/dist/services/Repository.d.ts.map +1 -1
- package/dist/services/Repository.js +1 -1
- package/dist/services/Store/Cosmos.js +2 -2
- package/dist/services/Store/Disk.js +3 -3
- package/dist/services/Store/Memory.js +1 -1
- package/dist/services/Store/Redis.js +1 -1
- package/dist/services/Store/index.js +1 -1
- package/dist/services/Store/service.js +1 -1
- package/dist/services/Store/utils.js +1 -1
- package/dist/services/simpledb/cosmosdb.d.ts +13 -0
- package/dist/services/simpledb/cosmosdb.d.ts.map +1 -0
- package/dist/services/simpledb/cosmosdb.js +88 -0
- package/dist/services/simpledb/diskdb.d.ts +12 -0
- package/dist/services/simpledb/diskdb.d.ts.map +1 -0
- package/dist/services/simpledb/diskdb.js +96 -0
- package/dist/services/simpledb/fileutil.d.ts +7 -0
- package/dist/services/simpledb/fileutil.d.ts.map +1 -0
- package/dist/services/simpledb/fileutil.js +25 -0
- package/dist/services/simpledb/index.d.ts +7 -0
- package/dist/services/simpledb/index.d.ts.map +1 -0
- package/dist/services/simpledb/index.js +7 -0
- package/dist/services/simpledb/memdb.d.ts +12 -0
- package/dist/services/simpledb/memdb.d.ts.map +1 -0
- package/dist/services/simpledb/memdb.js +55 -0
- package/dist/services/simpledb/mongodb.d.ts +13 -0
- package/dist/services/simpledb/mongodb.d.ts.map +1 -0
- package/dist/services/simpledb/mongodb.js +55 -0
- package/dist/services/simpledb/redisdb.d.ts +25 -0
- package/dist/services/simpledb/redisdb.d.ts.map +1 -0
- package/dist/services/simpledb/redisdb.js +105 -0
- package/dist/services/simpledb/shared.d.ts +63 -0
- package/dist/services/simpledb/shared.d.ts.map +1 -0
- package/dist/services/simpledb/shared.js +65 -0
- package/dist/services/simpledb/simpledb.d.ts +23 -0
- package/dist/services/simpledb/simpledb.d.ts.map +1 -0
- package/dist/services/simpledb/simpledb.js +56 -0
- package/package.json +216 -328
- package/_cjs/ext.cjs +0 -4
- package/_cjs/ext.cjs.map +0 -1
- package/_cjs/lib/fileUtil.cjs +0 -36
- package/_cjs/lib/fileUtil.cjs.map +0 -1
- package/_cjs/lib/filter/types/path/index.cjs.map +0 -1
- package/_cjs/services/CUPS/service.cjs +0 -15
- package/_cjs/services/CUPS/service.cjs.map +0 -1
- package/_cjs/services/CUPS.cjs +0 -113
- package/_cjs/services/CUPS.cjs.map +0 -1
- package/_cjs/services/Cache.cjs +0 -39
- package/_cjs/services/Cache.cjs.map +0 -1
- package/_cjs/services/ServiceBus.cjs +0 -69
- package/_cjs/services/ServiceBus.cjs.map +0 -1
- package/_cjs/services/memQueue.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/_internal/AtomicBoolean.cjs +0 -14
- package/_cjs/vendor/Cache/Cache/_internal/AtomicBoolean.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/_internal/AtomicNumber.cjs +0 -29
- package/_cjs/vendor/Cache/Cache/_internal/AtomicNumber.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/_internal/AtomicReference.cjs +0 -32
- package/_cjs/vendor/Cache/Cache/_internal/AtomicReference.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/_internal/CacheInternal.cjs +0 -266
- package/_cjs/vendor/Cache/Cache/_internal/CacheInternal.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/_internal/CacheState.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/_internal/KeySet.cjs +0 -67
- package/_cjs/vendor/Cache/Cache/_internal/KeySet.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/_internal/MapKey.cjs +0 -44
- package/_cjs/vendor/Cache/Cache/_internal/MapKey.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/_internal/MapValue.cjs +0 -33
- package/_cjs/vendor/Cache/Cache/_internal/MapValue.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/definition.cjs +0 -13
- package/_cjs/vendor/Cache/Cache/definition.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/operations/make.cjs +0 -20
- package/_cjs/vendor/Cache/Cache/operations/make.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/operations/makeWith.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache/operations.cjs +0 -28
- package/_cjs/vendor/Cache/Cache/operations.cjs.map +0 -1
- package/_cjs/vendor/Cache/Cache.cjs +0 -28
- package/_cjs/vendor/Cache/Cache.cjs.map +0 -1
- package/_cjs/vendor/Cache/CacheStats/definition.cjs +0 -13
- package/_cjs/vendor/Cache/CacheStats/definition.cjs.map +0 -1
- package/_cjs/vendor/Cache/CacheStats.cjs +0 -17
- package/_cjs/vendor/Cache/CacheStats.cjs.map +0 -1
- package/_cjs/vendor/Cache/EntryStats/definition.cjs +0 -11
- package/_cjs/vendor/Cache/EntryStats/definition.cjs.map +0 -1
- package/_cjs/vendor/Cache/EntryStats.cjs +0 -17
- package/_cjs/vendor/Cache/EntryStats.cjs.map +0 -1
- package/_cjs/vendor/Cache/Lookup/definition.cjs +0 -6
- package/_cjs/vendor/Cache/Lookup/definition.cjs.map +0 -1
- package/_cjs/vendor/Cache/Lookup.cjs +0 -17
- package/_cjs/vendor/Cache/Lookup.cjs.map +0 -1
- package/_cjs/vendor/Cache/index.cjs +0 -17
- package/_cjs/vendor/Cache/index.cjs.map +0 -1
- package/_src/ext.ts +0 -1
- package/_src/lib/fileUtil.ts +0 -56
- package/_src/services/CUPS/service.ts +0 -16
- package/_src/services/CUPS.ts +0 -105
- package/_src/services/Cache.ts +0 -45
- package/_src/services/ServiceBus.ts +0 -111
- package/_src/services/memQueue.ts +0 -30
- package/_src/vendor/Cache/Cache/_internal/AtomicBoolean.ts +0 -7
- package/_src/vendor/Cache/Cache/_internal/AtomicNumber.ts +0 -28
- package/_src/vendor/Cache/Cache/_internal/AtomicReference.ts +0 -30
- package/_src/vendor/Cache/Cache/_internal/CacheInternal.ts +0 -293
- package/_src/vendor/Cache/Cache/_internal/CacheState.ts +0 -56
- package/_src/vendor/Cache/Cache/_internal/KeySet.ts +0 -58
- package/_src/vendor/Cache/Cache/_internal/MapKey.ts +0 -43
- package/_src/vendor/Cache/Cache/_internal/MapValue.ts +0 -39
- package/_src/vendor/Cache/Cache/definition.ts +0 -112
- package/_src/vendor/Cache/Cache/operations/make.ts +0 -17
- package/_src/vendor/Cache/Cache/operations/makeWith.ts +0 -32
- package/_src/vendor/Cache/Cache/operations.ts +0 -4
- package/_src/vendor/Cache/Cache.ts +0 -4
- package/_src/vendor/Cache/CacheStats/definition.ts +0 -23
- package/_src/vendor/Cache/CacheStats.ts +0 -3
- package/_src/vendor/Cache/EntryStats/definition.ts +0 -19
- package/_src/vendor/Cache/EntryStats.ts +0 -3
- package/_src/vendor/Cache/Lookup/definition.ts +0 -15
- package/_src/vendor/Cache/Lookup.ts +0 -3
- package/_src/vendor/Cache/global.ts.bak +0 -23
- package/_src/vendor/Cache/index.ts +0 -4
- package/dist/ext.d.ts +0 -2
- package/dist/ext.d.ts.map +0 -1
- package/dist/ext.js +0 -2
- package/dist/lib/RequestContext.d.ts.map +0 -1
- package/dist/lib/RequestContext.js +0 -52
- package/dist/lib/api/authorization.jwt.d.ts.map +0 -1
- package/dist/lib/api/defaultErrorHandler.d.ts.map +0 -1
- package/dist/lib/api/reportError.d.ts.map +0 -1
- package/dist/lib/api/routing.d.ts.map +0 -1
- package/dist/lib/api/routing.js +0 -248
- package/dist/lib/api/setupRequest.d.ts.map +0 -1
- package/dist/lib/api/util.d.ts.map +0 -1
- package/dist/lib/api/util.js +0 -14
- package/dist/lib/api/writeDocs.d.ts.map +0 -1
- package/dist/lib/api/writeDocs.js +0 -23
- package/dist/lib/errorReporter.d.ts.map +0 -1
- package/dist/lib/errorReporter.js +0 -45
- package/dist/lib/ext/Array.d.ts.map +0 -1
- package/dist/lib/fileUtil.d.ts +0 -22
- package/dist/lib/fileUtil.d.ts.map +0 -1
- package/dist/lib/fileUtil.js +0 -23
- package/dist/lib/filter/types/errors.d.ts.map +0 -1
- package/dist/lib/filter/types/fields.d.ts.map +0 -1
- package/dist/lib/filter/types/index.d.ts.map +0 -1
- package/dist/lib/filter/types/path/common.d.ts.map +0 -1
- package/dist/lib/filter/types/path/eager.d.ts.map +0 -1
- package/dist/lib/filter/types/path/index.d.ts.map +0 -1
- package/dist/lib/filter/types/utils.d.ts.map +0 -1
- package/dist/lib/filter/types/validator.d.ts.map +0 -1
- package/dist/lib/filter.d.ts.map +0 -1
- package/dist/lib/filter.js +0 -171
- package/dist/lib/instrument.d.ts.map +0 -1
- package/dist/lib/rateLimit.d.ts.map +0 -1
- package/dist/services/CUPS/service.d.ts +0 -19
- package/dist/services/CUPS/service.d.ts.map +0 -1
- package/dist/services/CUPS/service.js +0 -5
- package/dist/services/CUPS.d.ts +0 -10
- package/dist/services/CUPS.d.ts.map +0 -1
- package/dist/services/CUPS.js +0 -89
- package/dist/services/Cache.d.ts +0 -28
- package/dist/services/Cache.d.ts.map +0 -1
- package/dist/services/Cache.js +0 -28
- package/dist/services/ServiceBus.d.ts +0 -26
- package/dist/services/ServiceBus.d.ts.map +0 -1
- package/dist/services/ServiceBus.js +0 -53
- package/dist/services/memQueue.d.ts +0 -18
- package/dist/services/memQueue.d.ts.map +0 -1
- package/dist/services/memQueue.js +0 -24
- package/dist/vendor/Cache/Cache/_internal/AtomicBoolean.d.ts +0 -5
- package/dist/vendor/Cache/Cache/_internal/AtomicBoolean.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/_internal/AtomicBoolean.js +0 -7
- package/dist/vendor/Cache/Cache/_internal/AtomicNumber.d.ts +0 -8
- package/dist/vendor/Cache/Cache/_internal/AtomicNumber.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/_internal/AtomicNumber.js +0 -22
- package/dist/vendor/Cache/Cache/_internal/AtomicReference.d.ts +0 -10
- package/dist/vendor/Cache/Cache/_internal/AtomicReference.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/_internal/AtomicReference.js +0 -25
- package/dist/vendor/Cache/Cache/_internal/CacheInternal.d.ts +0 -51
- package/dist/vendor/Cache/Cache/_internal/CacheInternal.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/_internal/CacheInternal.js +0 -253
- package/dist/vendor/Cache/Cache/_internal/CacheState.d.ts +0 -33
- package/dist/vendor/Cache/Cache/_internal/CacheState.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/_internal/CacheState.js +0 -21
- package/dist/vendor/Cache/Cache/_internal/KeySet.d.ts +0 -20
- package/dist/vendor/Cache/Cache/_internal/KeySet.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/_internal/KeySet.js +0 -61
- package/dist/vendor/Cache/Cache/_internal/MapKey.d.ts +0 -24
- package/dist/vendor/Cache/Cache/_internal/MapKey.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/_internal/MapKey.js +0 -37
- package/dist/vendor/Cache/Cache/_internal/MapValue.d.ts +0 -32
- package/dist/vendor/Cache/Cache/_internal/MapValue.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/_internal/MapValue.js +0 -24
- package/dist/vendor/Cache/Cache/definition.d.ts +0 -100
- package/dist/vendor/Cache/Cache/definition.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/definition.js +0 -5
- package/dist/vendor/Cache/Cache/operations/make.d.ts +0 -12
- package/dist/vendor/Cache/Cache/operations/make.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/operations/make.js +0 -12
- package/dist/vendor/Cache/Cache/operations/makeWith.d.ts +0 -14
- package/dist/vendor/Cache/Cache/operations/makeWith.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/operations/makeWith.js +0 -15
- package/dist/vendor/Cache/Cache/operations.d.ts +0 -3
- package/dist/vendor/Cache/Cache/operations.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache/operations.js +0 -4
- package/dist/vendor/Cache/Cache.d.ts +0 -3
- package/dist/vendor/Cache/Cache.d.ts.map +0 -1
- package/dist/vendor/Cache/Cache.js +0 -4
- package/dist/vendor/Cache/CacheStats/definition.d.ts +0 -19
- package/dist/vendor/Cache/CacheStats/definition.d.ts.map +0 -1
- package/dist/vendor/Cache/CacheStats/definition.js +0 -6
- package/dist/vendor/Cache/CacheStats.d.ts +0 -2
- package/dist/vendor/Cache/CacheStats.d.ts.map +0 -1
- package/dist/vendor/Cache/CacheStats.js +0 -3
- package/dist/vendor/Cache/EntryStats/definition.d.ts +0 -17
- package/dist/vendor/Cache/EntryStats/definition.d.ts.map +0 -1
- package/dist/vendor/Cache/EntryStats/definition.js +0 -4
- package/dist/vendor/Cache/EntryStats.d.ts +0 -2
- package/dist/vendor/Cache/EntryStats.d.ts.map +0 -1
- package/dist/vendor/Cache/EntryStats.js +0 -3
- package/dist/vendor/Cache/Lookup/definition.d.ts +0 -17
- package/dist/vendor/Cache/Lookup/definition.d.ts.map +0 -1
- package/dist/vendor/Cache/Lookup/definition.js +0 -2
- package/dist/vendor/Cache/Lookup.d.ts +0 -2
- package/dist/vendor/Cache/Lookup.d.ts.map +0 -1
- package/dist/vendor/Cache/Lookup.js +0 -3
- package/dist/vendor/Cache/index.d.ts +0 -5
- package/dist/vendor/Cache/index.d.ts.map +0 -1
- package/dist/vendor/Cache/index.js +0 -5
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import type { Clock } from "@effect/io/Clock"
|
|
2
|
-
import { Deferred, done as doneDeferred } from "@effect/io/Deferred"
|
|
3
|
-
import type { FiberId } from "@effect/io/Fiber/Id"
|
|
4
|
-
import { EmptyMutableQueue } from "@fp-ts/data/MutableQueue"
|
|
5
|
-
import { CacheStats } from "../../CacheStats.js"
|
|
6
|
-
import { EntryStats } from "../../EntryStats.js"
|
|
7
|
-
import type { Lookup } from "../../Lookup.js"
|
|
8
|
-
import type { Cache } from "../definition.js"
|
|
9
|
-
import { CacheURI } from "../definition.js"
|
|
10
|
-
import { CacheState } from "./CacheState.js"
|
|
11
|
-
import { MapKey } from "./MapKey.js"
|
|
12
|
-
import type { MapValue } from "./MapValue.js"
|
|
13
|
-
import { Complete, Pending, Refreshing } from "./MapValue.js"
|
|
14
|
-
|
|
15
|
-
export class CacheInternal<Key, Environment, Error, Value> implements Cache<Key, Error, Value> {
|
|
16
|
-
readonly [CacheURI] = {
|
|
17
|
-
_Key: (_: Key) => void 0,
|
|
18
|
-
_Error: (_: never) => _,
|
|
19
|
-
_Value: (_: never) => _
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
private cacheState: CacheState<Key, Error, Value>
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
25
|
-
readonly capacity: number,
|
|
26
|
-
readonly lookup: Lookup<Key, Environment, Error, Value>,
|
|
27
|
-
readonly timeToLive: (exit: Exit<Error, Value>) => DUR,
|
|
28
|
-
readonly clock: Clock,
|
|
29
|
-
readonly environment: Context<Environment>,
|
|
30
|
-
readonly fiberId: FiberId
|
|
31
|
-
) {
|
|
32
|
-
this.cacheState = CacheState.initial<Key, Error, Value>()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
get size(): Effect<never, never, number> {
|
|
36
|
-
return Effect(() => this.cacheState.map.size)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
get entries(): Effect<never, never, Chunk<readonly [Key, Value]>> {
|
|
40
|
-
return Effect(() => {
|
|
41
|
-
const entries: Array<readonly [Key, Value]> = []
|
|
42
|
-
for (const [key, value] of this.cacheState.map) {
|
|
43
|
-
if (value._tag === "Complete" && value.exit.isSuccess()) {
|
|
44
|
-
entries.push([key, value.exit.value] as const)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return Chunk.fromIterable(entries)
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get values(): Effect<never, never, Chunk<Value>> {
|
|
52
|
-
return Effect(() => {
|
|
53
|
-
const values: Array<Value> = []
|
|
54
|
-
for (const [_, value] of this.cacheState.map) {
|
|
55
|
-
if (value._tag === "Complete" && value.exit.isSuccess()) {
|
|
56
|
-
values.push(value.exit.value)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return Chunk.fromIterable(values)
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get cacheStats(): Effect<never, never, CacheStats> {
|
|
64
|
-
return Effect(CacheStats(
|
|
65
|
-
this.cacheState.hits,
|
|
66
|
-
this.cacheState.misses,
|
|
67
|
-
this.cacheState.map.size
|
|
68
|
-
))
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
entryStats(k: Key): Effect<never, never, Opt<EntryStats>> {
|
|
72
|
-
return Effect(() => {
|
|
73
|
-
const value = this.cacheState.map.get(k).value
|
|
74
|
-
if (value == null) {
|
|
75
|
-
return Opt.none
|
|
76
|
-
}
|
|
77
|
-
switch (value._tag) {
|
|
78
|
-
case "Pending": {
|
|
79
|
-
return Opt.none
|
|
80
|
-
}
|
|
81
|
-
case "Complete": {
|
|
82
|
-
return Opt(EntryStats(value.entryStats.loadedMillis))
|
|
83
|
-
}
|
|
84
|
-
case "Refreshing": {
|
|
85
|
-
return Opt(EntryStats(value.complete.entryStats.loadedMillis))
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get(k: Key): Effect<never, Error, Value> {
|
|
92
|
-
return Effect.suspendSucceed(() => {
|
|
93
|
-
let key: MapKey<Key> | undefined = undefined
|
|
94
|
-
let deferred: Deferred<Error, Value> | undefined = undefined
|
|
95
|
-
let value = this.cacheState.map.get(k).value
|
|
96
|
-
if (value == null) {
|
|
97
|
-
deferred = Deferred.unsafeMake<Error, Value>(this.fiberId)
|
|
98
|
-
key = new MapKey(k)
|
|
99
|
-
if (this.cacheState.map.has(k)) {
|
|
100
|
-
value = this.cacheState.map.get(k).value!
|
|
101
|
-
} else {
|
|
102
|
-
this.cacheState.map.set(k, new Pending(key, deferred))
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (value == null) {
|
|
106
|
-
this.trackAccess(key!)
|
|
107
|
-
this.trackMiss()
|
|
108
|
-
return this.lookupValueOf(k, deferred!)
|
|
109
|
-
}
|
|
110
|
-
switch (value._tag) {
|
|
111
|
-
case "Pending": {
|
|
112
|
-
this.trackAccess(value.key)
|
|
113
|
-
this.trackHit()
|
|
114
|
-
return value.deferred.await
|
|
115
|
-
}
|
|
116
|
-
case "Complete": {
|
|
117
|
-
this.trackAccess(value.key)
|
|
118
|
-
this.trackHit()
|
|
119
|
-
if (this.hasExpired(value.timeToLiveMillis)) {
|
|
120
|
-
const found = this.cacheState.map.get(k).value
|
|
121
|
-
if (Equals.equals(found, value)) {
|
|
122
|
-
this.cacheState.map.remove(k)
|
|
123
|
-
}
|
|
124
|
-
return this.get(k)
|
|
125
|
-
}
|
|
126
|
-
return value.exit.done
|
|
127
|
-
}
|
|
128
|
-
case "Refreshing": {
|
|
129
|
-
this.trackAccess(value.complete.key)
|
|
130
|
-
this.trackHit()
|
|
131
|
-
if (this.hasExpired(value.complete.timeToLiveMillis)) {
|
|
132
|
-
return value.deferred.await
|
|
133
|
-
}
|
|
134
|
-
return value.complete.exit.done
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
set(key: Key, value: Value): Effect<never, never, void> {
|
|
141
|
-
return Effect(() => {
|
|
142
|
-
const now = this.clock.currentTimeMillis().unsafeRunSync
|
|
143
|
-
const lookupResult = Exit.succeed(value)
|
|
144
|
-
this.cacheState.map.set(
|
|
145
|
-
key,
|
|
146
|
-
new Complete(
|
|
147
|
-
new MapKey(key),
|
|
148
|
-
lookupResult,
|
|
149
|
-
EntryStats(now),
|
|
150
|
-
now + this.timeToLive(lookupResult).millis
|
|
151
|
-
)
|
|
152
|
-
)
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
contains(key: Key): Effect<never, never, boolean> {
|
|
157
|
-
return Effect(() => this.cacheState.map.has(key))
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
refresh(k: Key): Effect<never, Error, void> {
|
|
161
|
-
return Effect.suspendSucceed(() => {
|
|
162
|
-
const deferred = Deferred.unsafeMake<Error, Value>(this.fiberId)
|
|
163
|
-
let value = this.cacheState.map.get(k).value
|
|
164
|
-
if (value == null) {
|
|
165
|
-
if (this.cacheState.map.has(k)) {
|
|
166
|
-
value = this.cacheState.map.get(k).value!
|
|
167
|
-
} else {
|
|
168
|
-
this.cacheState.map.set(k, new Pending(new MapKey(k), deferred))
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
if (value == null) {
|
|
172
|
-
return this.lookupValueOf(k, deferred).asUnit
|
|
173
|
-
}
|
|
174
|
-
switch (value._tag) {
|
|
175
|
-
case "Pending": {
|
|
176
|
-
return value.deferred.await.asUnit
|
|
177
|
-
}
|
|
178
|
-
case "Complete": {
|
|
179
|
-
if (this.hasExpired(value.timeToLiveMillis)) {
|
|
180
|
-
const found = this.cacheState.map.get(k).value!
|
|
181
|
-
if (Equals.equals(found, value)) {
|
|
182
|
-
this.cacheState.map.remove(k)
|
|
183
|
-
}
|
|
184
|
-
return this.get(k).asUnit
|
|
185
|
-
}
|
|
186
|
-
// Only trigger the lookup if we're still the current value
|
|
187
|
-
return this.lookupValueOf(value.key.value, deferred)
|
|
188
|
-
.when(() => {
|
|
189
|
-
const current = this.cacheState.map.get(k).value
|
|
190
|
-
if (Equals.equals(current, value)) {
|
|
191
|
-
this.cacheState.map.set(
|
|
192
|
-
k,
|
|
193
|
-
new Refreshing(deferred, value as Complete<Key, Error, Value>)
|
|
194
|
-
)
|
|
195
|
-
return true
|
|
196
|
-
}
|
|
197
|
-
return false
|
|
198
|
-
})
|
|
199
|
-
.asUnit
|
|
200
|
-
}
|
|
201
|
-
case "Refreshing": {
|
|
202
|
-
return value.deferred.await.asUnit
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
invalidate(key: Key): Effect<never, never, void> {
|
|
209
|
-
return Effect(() => {
|
|
210
|
-
this.cacheState.map.remove(key)
|
|
211
|
-
})
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
invalidateAll: Effect<never, never, void> = Effect(() => {
|
|
215
|
-
this.cacheState.map = MutableHashMap.empty<Key, MapValue<Key, Error, Value>>()
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
private trackHit(): void {
|
|
219
|
-
this.cacheState.hits = this.cacheState.hits + 1
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
private trackMiss(): void {
|
|
223
|
-
this.cacheState.misses = this.cacheState.misses + 1
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
private trackAccess(key: MapKey<Key>): void {
|
|
227
|
-
this.cacheState.accesses.offer(key)
|
|
228
|
-
if (this.cacheState.updating.compareAndSet(false, true)) {
|
|
229
|
-
let loop = true
|
|
230
|
-
while (loop) {
|
|
231
|
-
const key = this.cacheState.accesses.poll(EmptyMutableQueue)
|
|
232
|
-
if (key === EmptyMutableQueue) {
|
|
233
|
-
loop = false
|
|
234
|
-
} else {
|
|
235
|
-
this.cacheState.keys.add(key)
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
let size = this.cacheState.map.size
|
|
239
|
-
loop = size > this.capacity
|
|
240
|
-
while (loop) {
|
|
241
|
-
const key = this.cacheState.keys.remove()
|
|
242
|
-
if (key != null) {
|
|
243
|
-
if (this.cacheState.map.remove(key.value) != null) {
|
|
244
|
-
size = size - 1
|
|
245
|
-
loop = size > this.capacity
|
|
246
|
-
}
|
|
247
|
-
} else {
|
|
248
|
-
loop = false
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
this.cacheState.updating.set(false)
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
private lookupValueOf(key: Key, deferred: Deferred<Error, Value>): Effect<never, Error, Value> {
|
|
256
|
-
return this.lookup(key)
|
|
257
|
-
.provideEnvironment(this.environment)
|
|
258
|
-
.exit
|
|
259
|
-
.flatMap(exit => {
|
|
260
|
-
const now = this.clock.currentTimeMillis().unsafeRunSync
|
|
261
|
-
const entryStats = EntryStats(now)
|
|
262
|
-
this.cacheState.map.set(
|
|
263
|
-
key,
|
|
264
|
-
new Complete(
|
|
265
|
-
new MapKey(key),
|
|
266
|
-
exit,
|
|
267
|
-
entryStats,
|
|
268
|
-
now + this.timeToLive(exit).millis
|
|
269
|
-
)
|
|
270
|
-
)
|
|
271
|
-
// TODO: later for updated Deferred handling
|
|
272
|
-
return doneDeferred(deferred)(exit).zipRight(exit.done)
|
|
273
|
-
})
|
|
274
|
-
.onInterrupt(() =>
|
|
275
|
-
deferred.interrupt.zipRight(Effect(() => {
|
|
276
|
-
this.cacheState.map.remove(key)
|
|
277
|
-
}))
|
|
278
|
-
)
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
private hasExpired(timeToLiveMillis: number): boolean {
|
|
282
|
-
return this.clock.currentTimeMillis().unsafeRunSync > timeToLiveMillis
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* @tsplus macro remove
|
|
288
|
-
*/
|
|
289
|
-
export function concreteCache<Key, Error, Value>(
|
|
290
|
-
_: Cache<Key, Error, Value>
|
|
291
|
-
): asserts _ is CacheInternal<Key, unknown, Error, Value> {
|
|
292
|
-
//
|
|
293
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { AtomicBoolean } from "./AtomicBoolean.js"
|
|
2
|
-
import { KeySet } from "./KeySet.js"
|
|
3
|
-
import type { MapKey } from "./MapKey.js"
|
|
4
|
-
import type { MapValue } from "./MapValue.js"
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `CacheState` represents the mutable state underlying the cache.
|
|
8
|
-
*
|
|
9
|
-
* @tsplus type effect/cache/Cache/CacheState
|
|
10
|
-
*/
|
|
11
|
-
export interface CacheState<Key, Error, Value> {
|
|
12
|
-
map: MutableHashMap<Key, MapValue<Key, Error, Value>>
|
|
13
|
-
keys: KeySet<Key>
|
|
14
|
-
accesses: MutableQueue<MapKey<Key>>
|
|
15
|
-
updating: AtomicBoolean
|
|
16
|
-
hits: number
|
|
17
|
-
misses: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @tsplus type effect/cache/Cache/CacheState.Ops
|
|
22
|
-
*/
|
|
23
|
-
export interface CacheStateOps {
|
|
24
|
-
<Key, Error, Value>(
|
|
25
|
-
map: MutableHashMap<Key, MapValue<Key, Error, Value>>,
|
|
26
|
-
keys: KeySet<Key>,
|
|
27
|
-
accesses: MutableQueue<MapKey<Key>>,
|
|
28
|
-
updating: AtomicBoolean,
|
|
29
|
-
hits: number,
|
|
30
|
-
misses: number
|
|
31
|
-
): CacheState<Key, Error, Value>
|
|
32
|
-
}
|
|
33
|
-
export const CacheState: CacheStateOps = (map, keys, accesses, updating, hits, misses) => ({
|
|
34
|
-
map,
|
|
35
|
-
keys,
|
|
36
|
-
accesses,
|
|
37
|
-
updating,
|
|
38
|
-
hits,
|
|
39
|
-
misses
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Constructs an initial cache state.
|
|
44
|
-
*
|
|
45
|
-
* @tsplus static effect/cache/Cache/CacheState.Ops initial
|
|
46
|
-
*/
|
|
47
|
-
export function initial<Key, Error, Value>(): CacheState<Key, Error, Value> {
|
|
48
|
-
return CacheState(
|
|
49
|
-
MutableHashMap.empty(),
|
|
50
|
-
new KeySet(),
|
|
51
|
-
MutableQueue.unbounded(),
|
|
52
|
-
new AtomicBoolean(false),
|
|
53
|
-
0,
|
|
54
|
-
0
|
|
55
|
-
)
|
|
56
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { MapKey } from "./MapKey.js"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A `KeySet` is a sorted set of keys in the cache ordered by last access.
|
|
5
|
-
* For efficiency, the set is implemented in terms of a doubly linked list
|
|
6
|
-
* and is not safe for concurrent access.
|
|
7
|
-
*/
|
|
8
|
-
export class KeySet<Key> {
|
|
9
|
-
head: MapKey<Key> | undefined = undefined
|
|
10
|
-
tail: MapKey<Key> | undefined = undefined
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Adds the specified key to the set.
|
|
14
|
-
*/
|
|
15
|
-
add(key: MapKey<Key>): void {
|
|
16
|
-
if (!Equals.equals(key, this.tail)) {
|
|
17
|
-
if (this.tail != null) {
|
|
18
|
-
const previous = key.previous
|
|
19
|
-
const next = key.next
|
|
20
|
-
if (next != null) {
|
|
21
|
-
key.next = undefined
|
|
22
|
-
if (previous != null) {
|
|
23
|
-
previous.next = next
|
|
24
|
-
next.previous = previous
|
|
25
|
-
} else {
|
|
26
|
-
this.head = next
|
|
27
|
-
this.head.previous = undefined
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
this.tail.next = key
|
|
31
|
-
key.previous = this.tail
|
|
32
|
-
this.tail = key
|
|
33
|
-
} else {
|
|
34
|
-
this.head = key
|
|
35
|
-
this.tail = key
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Removes the lowest priority key from the set.
|
|
42
|
-
*/
|
|
43
|
-
remove(): MapKey<Key> | undefined {
|
|
44
|
-
const key = this.head
|
|
45
|
-
if (key != null) {
|
|
46
|
-
const next = key.next
|
|
47
|
-
if (next) {
|
|
48
|
-
key.next = undefined
|
|
49
|
-
this.head = next
|
|
50
|
-
this.head.previous = undefined
|
|
51
|
-
} else {
|
|
52
|
-
this.head = undefined
|
|
53
|
-
this.tail = undefined
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return key
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { symbolEqual, symbolHash } from "@fp-ts/data/Equal"
|
|
2
|
-
|
|
3
|
-
export const MapKeyURI = Symbol.for("@effect/cache/Cache/MapKey")
|
|
4
|
-
export type MapKeyURI = typeof MapKeyURI
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A `MapKey` represents a key in the cache. It contains mutable references
|
|
8
|
-
* to the previous key and next key in the `KeySet` to support an efficient
|
|
9
|
-
* implementation of a sorted set of keys.
|
|
10
|
-
*/
|
|
11
|
-
export class MapKey<Key> implements Equals {
|
|
12
|
-
readonly [MapKeyURI]: MapKeyURI = MapKeyURI
|
|
13
|
-
|
|
14
|
-
previous: MapKey<Key> | undefined = undefined
|
|
15
|
-
next: MapKey<Key> | undefined = undefined
|
|
16
|
-
|
|
17
|
-
constructor(readonly value: Key) {}
|
|
18
|
-
|
|
19
|
-
[symbolHash](): number {
|
|
20
|
-
return Equals.hashCombine(
|
|
21
|
-
Equals.hashCombine(
|
|
22
|
-
Equals.hash(this.next)
|
|
23
|
-
)(Equals.hash(this.previous))
|
|
24
|
-
)(Equals.hash(this.value))
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
[symbolEqual](that: unknown): boolean {
|
|
28
|
-
if (this === that) {
|
|
29
|
-
return true
|
|
30
|
-
}
|
|
31
|
-
return isMapKey(that) &&
|
|
32
|
-
Equals.equals(this.value, that.value) &&
|
|
33
|
-
Equals.equals(this.previous, that.previous) &&
|
|
34
|
-
Equals.equals(this.next, that.next)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @tsplus static effect/cache/Cache/MapKey.Ops is
|
|
40
|
-
*/
|
|
41
|
-
export function isMapKey(u: unknown): u is MapKey<unknown> {
|
|
42
|
-
return typeof u === "object" && u != null && MapKeyURI in u
|
|
43
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { EntryStats } from "../../EntryStats/definition.js"
|
|
2
|
-
import type { MapKey } from "./MapKey.js"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A `MapValue` represents a value in the cache. A value may either be
|
|
6
|
-
* `Pending` with a `Deferred` that will contain the result of computing the
|
|
7
|
-
* lookup function, when it is available, or `Complete` with an `Exit` value
|
|
8
|
-
* that contains the result of computing the lookup function.
|
|
9
|
-
*/
|
|
10
|
-
export type MapValue<Key, Error, Value> =
|
|
11
|
-
| Pending<Key, Error, Value>
|
|
12
|
-
| Complete<Key, Error, Value>
|
|
13
|
-
| Refreshing<Key, Error, Value>
|
|
14
|
-
|
|
15
|
-
export class Pending<Key, Error, Value> {
|
|
16
|
-
readonly _tag = "Pending"
|
|
17
|
-
constructor(
|
|
18
|
-
readonly key: MapKey<Key>,
|
|
19
|
-
readonly deferred: Deferred<Error, Value>
|
|
20
|
-
) {}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class Complete<Key, Error, Value> {
|
|
24
|
-
readonly _tag = "Complete"
|
|
25
|
-
constructor(
|
|
26
|
-
readonly key: MapKey<Key>,
|
|
27
|
-
readonly exit: Exit<Error, Value>,
|
|
28
|
-
readonly entryStats: EntryStats,
|
|
29
|
-
readonly timeToLiveMillis: number
|
|
30
|
-
) {}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class Refreshing<Key, Error, Value> {
|
|
34
|
-
readonly _tag = "Refreshing"
|
|
35
|
-
constructor(
|
|
36
|
-
readonly deferred: Deferred<Error, Value>,
|
|
37
|
-
readonly complete: Complete<Key, Error, Value>
|
|
38
|
-
) {}
|
|
39
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { CacheStats } from "../CacheStats.js"
|
|
2
|
-
import type { EntryStats } from "../EntryStats.js"
|
|
3
|
-
|
|
4
|
-
export const CacheURI = Symbol.for("@effect/cache/Cache")
|
|
5
|
-
export type CacheURI = typeof CacheURI
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A `Cache` is defined in terms of a lookup function that, given a key of
|
|
9
|
-
* type `Key`, can either fail with an error of type `Error` or succeed with a
|
|
10
|
-
* value of type `Value`. Getting a value from the cache will either return
|
|
11
|
-
* the previous result of the lookup function if it is available or else
|
|
12
|
-
* compute a new result with the lookup function, put it in the cache, and
|
|
13
|
-
* return it.
|
|
14
|
-
*
|
|
15
|
-
* A cache also has a specified capacity and time to live. When the cache is
|
|
16
|
-
* at capacity the least recently accessed values in the cache will be
|
|
17
|
-
* removed to make room for new values. Getting a value with a life older than
|
|
18
|
-
* the specified time to live will result in a new value being computed with
|
|
19
|
-
* the lookup function and returned when available.
|
|
20
|
-
*
|
|
21
|
-
* The cache is safe for concurrent access. If multiple fibers attempt to get
|
|
22
|
-
* the same key the lookup function will only be computed once and the result
|
|
23
|
-
* will be returned to all fibers.
|
|
24
|
-
*
|
|
25
|
-
* @tsplus type effect/cache/Cache
|
|
26
|
-
*/
|
|
27
|
-
export interface Cache<Key, Error, Value> {
|
|
28
|
-
readonly [CacheURI]: {
|
|
29
|
-
readonly _Key: (_: Key) => void
|
|
30
|
-
readonly _Error: (_: never) => Error
|
|
31
|
-
readonly _Value: (_: never) => Value
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Returns the approximate number of values in the cache.
|
|
36
|
-
*/
|
|
37
|
-
readonly size: Effect<never, never, number>
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Returns an approximation of the entries in the cache.
|
|
41
|
-
*/
|
|
42
|
-
readonly entries: Effect<never, never, Chunk<readonly [Key, Value]>>
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Returns an approximation of the values in the cache.
|
|
46
|
-
*/
|
|
47
|
-
readonly values: Effect<never, never, Chunk<Value>>
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Returns statistics for this cache.
|
|
51
|
-
*/
|
|
52
|
-
readonly cacheStats: Effect<never, never, CacheStats>
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Returns statistics for the specified entry, if it exists.
|
|
56
|
-
*/
|
|
57
|
-
readonly entryStats: (key: Key) => Effect<never, never, Opt<EntryStats>>
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Retrieves the value associated with the specified key if it exists.
|
|
61
|
-
* Otherwise computes the value with the lookup function, puts it in the
|
|
62
|
-
* cache, and returns it.
|
|
63
|
-
*/
|
|
64
|
-
readonly get: (key: Key) => Effect<never, Error, Value>
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Associates the specified value to the specified key in the cache.
|
|
68
|
-
*/
|
|
69
|
-
readonly set: (key: Key, value: Value) => Effect<never, never, void>
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Returns whether a value associated with the specified key exists in the
|
|
73
|
-
* cache.
|
|
74
|
-
*/
|
|
75
|
-
readonly contains: (key: Key) => Effect<never, never, boolean>
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Computes the value associated with the specified key, with the lookup
|
|
79
|
-
* function, and puts it in the cache. The difference between this and
|
|
80
|
-
* `get` method is that `refresh` triggers (re)computation of the value
|
|
81
|
-
* without invalidating it in the cache, so any request to the associated
|
|
82
|
-
* key can still be served while the value is being re-computed/retrieved
|
|
83
|
-
* by the lookup function. Additionally, `refresh` always triggers the
|
|
84
|
-
* lookup function, disregarding the last `Error`.
|
|
85
|
-
*/
|
|
86
|
-
readonly refresh: (key: Key) => Effect<never, Error, void>
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Invalidates the value associated with the specified key.
|
|
90
|
-
*/
|
|
91
|
-
readonly invalidate: (key: Key) => Effect<never, never, void>
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Invalidates all values in the cache.
|
|
95
|
-
*/
|
|
96
|
-
readonly invalidateAll: Effect<never, never, void>
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @tsplus type effect/cache/Cache.Ops
|
|
101
|
-
*/
|
|
102
|
-
export interface CacheOps {
|
|
103
|
-
readonly $: CacheAspects
|
|
104
|
-
}
|
|
105
|
-
export const Cache: CacheOps = {
|
|
106
|
-
$: {}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @tsplus type effect/cache/Cache.Aspects
|
|
111
|
-
*/
|
|
112
|
-
export interface CacheAspects {}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Lookup } from "../../Lookup/definition.js"
|
|
2
|
-
import { Cache } from "../definition.js"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Constructs a new cache with the specified capacity, time to live, and
|
|
6
|
-
* lookup function.
|
|
7
|
-
*
|
|
8
|
-
* @tsplus static effect/cache/Cache.Ops make
|
|
9
|
-
*/
|
|
10
|
-
export function make<Key, Environment, Error, Value>(
|
|
11
|
-
capacity: number,
|
|
12
|
-
timeToLive: DUR,
|
|
13
|
-
lookup: Lookup<Key, Environment, Error, Value>,
|
|
14
|
-
__tsplusTrace?: string
|
|
15
|
-
): Effect<Environment, never, Cache<Key, Error, Value>> {
|
|
16
|
-
return Cache.makeWith(capacity, lookup, () => timeToLive)
|
|
17
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Lookup } from "../../Lookup/definition.js"
|
|
2
|
-
import { CacheInternal } from "../_internal/CacheInternal.js"
|
|
3
|
-
import type { Cache } from "../definition.js"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Constructs a new cache with the specified capacity, time to live, and
|
|
7
|
-
* lookup function, where the time to live can depend on the `Exit` value
|
|
8
|
-
* returned by the lookup function.
|
|
9
|
-
*
|
|
10
|
-
* @tsplus static effect/cache/Cache.Ops makeWith
|
|
11
|
-
*/
|
|
12
|
-
export function makeWith<Key, Environment, Error, Value>(
|
|
13
|
-
capacity: number,
|
|
14
|
-
lookup: Lookup<Key, Environment, Error, Value>,
|
|
15
|
-
timeToLive: (exit: Exit<Error, Value>) => DUR,
|
|
16
|
-
__tsplusTrace?: string
|
|
17
|
-
): Effect<Environment, never, Cache<Key, Error, Value>> {
|
|
18
|
-
return Effect.clockWith(clock =>
|
|
19
|
-
Effect.environment<Environment>().flatMap(environment =>
|
|
20
|
-
Effect.fiberId().map(fiberId =>
|
|
21
|
-
new CacheInternal(
|
|
22
|
-
capacity,
|
|
23
|
-
lookup,
|
|
24
|
-
timeToLive,
|
|
25
|
-
clock,
|
|
26
|
-
environment,
|
|
27
|
-
fiberId
|
|
28
|
-
)
|
|
29
|
-
)
|
|
30
|
-
)
|
|
31
|
-
)
|
|
32
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A `CacheStats` represents a snapshot of statistics for the cache as of a
|
|
3
|
-
* point in time.
|
|
4
|
-
*
|
|
5
|
-
* @tsplus type effect/cache/CacheStats
|
|
6
|
-
*/
|
|
7
|
-
export interface CacheStats {
|
|
8
|
-
readonly hits: number
|
|
9
|
-
readonly misses: number
|
|
10
|
-
readonly size: number
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @tsplus type effect/cache/CacheStats.Ops
|
|
15
|
-
*/
|
|
16
|
-
export interface CacheStatsOps {
|
|
17
|
-
(hits: number, misses: number, size: number): CacheStats
|
|
18
|
-
}
|
|
19
|
-
export const CacheStats: CacheStatsOps = (hits, misses, size) => ({
|
|
20
|
-
hits,
|
|
21
|
-
misses,
|
|
22
|
-
size
|
|
23
|
-
})
|