Skip to content

TTL on KV and OS differ in unit size (nano/milli) #228

Open
@StephanMeijer

Description

@StephanMeijer

Observed behavior

Objm.create has the following signature:

    /**
     * Creates and opens the specified ObjectStore. If the ObjectStore already exists,
     * it opens the existing ObjectStore.
     * @param name
     * @param opts
     */
    create(name: string, opts?: Partial<ObjectStoreOptions>): Promise<ObjectStore>;

And ObjectStoreOptions is defined as the following

export type ObjectStoreOptions = {
    // ...

    /**
     * The time to live for entries in the object store specified
     * as nanoseconds. Use the `nanos()` function to convert millis to
     * nanos.
     */
    ttl?: Nanos;

    // ...
};

While Kvm.create has the following signature:

    /**
     * Creates and opens the specified KV. If the KV already exists, it opens the existing KV.
     * @param name
     * @param opts
     */
    create(name: string, opts?: Partial<KvOptions>): Promise<KV>;

And KvOptions is defined as the following:

export type KvOptions = KvLimits & {
    // ...
};
export type KvLimits = {
    // ...

    /**
     * The maximum number of millis the key should live
     * in the KV. The server will automatically remove
     * keys older than this amount. Note that deletion of
     * delete markers are not performed.
     */
    ttl: number;
    // ...
};

Expected behavior

I expect both to be either in milli or nano-seconds. As an end-user I'd prefer milliseconds so I do not have to convert milliseconds to nanoseconds.

Server and client version

    "@nats-io/jetstream": "^3.0.0-40",
    "@nats-io/kv": "^3.0.0-34",
    "@nats-io/nats-core": "^3.0.0-54",
    "@nats-io/obj": "^3.0.0-36",
    "@nats-io/transport-node": "^3.0.0-38",

Host environment

No response

Steps to reproduce

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions