Skip to main content

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

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new NatsConfigStore(config?): NatsConfigStore

Parameters

NameTypeDescription
config?Object-
config.cacheTtl?numberCache time to live in ms
config.enableCache?booleanEnable cache
config.enableGet?booleanEnable generally get method
config.enableRemove?booleanEnable generally remove method
config.enableSet?booleanEnable generally set method
config.keyValueStoreName?string-
config.logLevel?LogLevelNameA log level for new logger if logger is not set
config.logger?LoggerA logger instance

Returns

NatsConfigStore

Overrides

ConfigStoreBaseClass<NatsConfigStoreConfig>.constructor

Defined in

nats-config-store/src/NatsConfigStore.impl.ts:34open in new window

Properties

config

config: Object

Type declaration

NameTypeDescription
cacheTtl?numberCache time to live in ms
enableCache?booleanEnable cache
enableGet?booleanEnable generally get method
enableRemove?booleanEnable generally remove method
enableSet?booleanEnable generally set method
keyValueStoreNamestring-
logLevel?LogLevelNameA log level for new logger if logger is not set
logger?LoggerA 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:29open in new window


kv

kv: undefined | KV

Defined in

nats-config-store/src/NatsConfigStore.impl.ts:32open in new window


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:31open in new window

Methods

destroy

destroy(): Promise<void>

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.destroy

Defined in

nats-config-store/src/NatsConfigStore.impl.ts:123open in new window


getConfig

getConfig(...stateNames): Promise<Record<string, unknown>>

Parameters

NameType
...stateNamesstring[]

Returns

Promise<Record<string, unknown>>

Overrides

ConfigStoreBaseClass.getConfig

Defined in

nats-config-store/src/NatsConfigStore.impl.ts:70open in new window


getStore

getStore(): Promise<KV>

Returns

Promise<KV>

Defined in

nats-config-store/src/NatsConfigStore.impl.ts:42open in new window


removeConfig

removeConfig(stateName): Promise<void>

Parameters

NameType
stateNamestring

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.removeConfig

Defined in

nats-config-store/src/NatsConfigStore.impl.ts:91open in new window


setConfig

setConfig(stateName, stateValue): Promise<void>

Parameters

NameType
stateNamestring
stateValueunknown

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.setConfig

Defined in

nats-config-store/src/NatsConfigStore.impl.ts:107open in new window

Last update:
Contributors: Sebastian Wessel