Class: NatsConfigStore
PURISTA API / Modules / @purista/nats-config-store / NatsConfigStore
Class: NatsConfigStore
@purista/nats-config-store.NatsConfigStore
A config store for using NATS (with JetStream) as storage. JetStream must be enabled at the NATS broker.
Example
const config = {
port: 8222
}
const store = new NatsConfigStore({ config })
await store.setConfig('configKey',{ myConfig: 'value' })
let value = await store.getConfig('configKey')
console.log(value) // outputs: { configKey: { myConfig: 'value' } }
await store.removeConfig('configKey')
value = await store.getConfig('configKey')
console.log(value) // outputs: undefined
Hierarchy
ConfigStoreBaseClass
<NatsConfigStoreConfig
>↳
NatsConfigStore
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new NatsConfigStore(config?
): NatsConfigStore
Parameters
Name | Type | Description |
---|---|---|
config? | Object | - |
config.cacheTtl? | number | Cache time to live in ms |
config.enableCache? | boolean | Enable cache |
config.enableGet? | boolean | Enable generally get method |
config.enableRemove? | boolean | Enable generally remove method |
config.enableSet? | boolean | Enable generally set method |
config.keyValueStoreName? | string | - |
config.logLevel? | LogLevelName | A log level for new logger if logger is not set |
config.logger? | Logger | A logger instance |
Returns
Overrides
ConfigStoreBaseClass<NatsConfigStoreConfig>.constructor
Defined in
nats-config-store/src/NatsConfigStore.impl.ts:34
Properties
config
• config: Object
Type declaration
Name | Type | Description |
---|---|---|
cacheTtl? | number | Cache time to live in ms |
enableCache? | boolean | Enable cache |
enableGet? | boolean | Enable generally get method |
enableRemove? | boolean | Enable generally remove method |
enableSet? | boolean | Enable generally set method |
keyValueStoreName | string | - |
logLevel? | LogLevelName | A log level for new logger if logger is not set |
logger? | Logger | A logger instance |
Inherited from
ConfigStoreBaseClass.config
Defined in
core/lib/types/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:10
connection
• connection: undefined
| NatsConnection
Defined in
nats-config-store/src/NatsConfigStore.impl.ts:29
kv
• kv: undefined
| KV
Defined in
nats-config-store/src/NatsConfigStore.impl.ts:32
logger
• logger: Logger
Inherited from
ConfigStoreBaseClass.logger
Defined in
core/lib/types/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:9
name
• name: string
Inherited from
ConfigStoreBaseClass.name
Defined in
core/lib/types/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:11
sc
• sc: Codec
<unknown
>
Defined in
nats-config-store/src/NatsConfigStore.impl.ts:31
Methods
destroy
▸ destroy(): Promise
<void
>
Returns
Promise
<void
>
Overrides
ConfigStoreBaseClass.destroy
Defined in
nats-config-store/src/NatsConfigStore.impl.ts:123
getConfig
▸ getConfig(...stateNames
): Promise
<Record
<string
, unknown
>>
Parameters
Name | Type |
---|---|
...stateNames | string [] |
Returns
Promise
<Record
<string
, unknown
>>
Overrides
ConfigStoreBaseClass.getConfig
Defined in
nats-config-store/src/NatsConfigStore.impl.ts:70
getStore
▸ getStore(): Promise
<KV
>
Returns
Promise
<KV
>
Defined in
nats-config-store/src/NatsConfigStore.impl.ts:42
removeConfig
▸ removeConfig(stateName
): Promise
<void
>
Parameters
Name | Type |
---|---|
stateName | string |
Returns
Promise
<void
>
Overrides
ConfigStoreBaseClass.removeConfig
Defined in
nats-config-store/src/NatsConfigStore.impl.ts:91
setConfig
▸ setConfig(stateName
, stateValue
): Promise
<void
>
Parameters
Name | Type |
---|---|
stateName | string |
stateValue | unknown |
Returns
Promise
<void
>
Overrides
ConfigStoreBaseClass.setConfig