Type Alias Opts<V>

Opts<V>: {
    capacity?: number;
    capacityPerResource?: number;
    debug?: boolean;
    free?: ((v: V) => void);
    fullPolicy?: FullPolicy;
    generate?: (() => V);
    resourcesWithoutUserExpireAfterMs?: number;
    userExpireAfterMs?: number;
}

Pool options

Type Parameters

  • V

Type declaration

  • Optional Readonlycapacity?: number

    Maximum number of resources for this pool

  • Optional ReadonlycapacityPerResource?: number

    Maximum number of users per resource. Defaults to 1

  • Optional Readonlydebug?: boolean

    If true, additional logging will trace activity of pool. Default: false

  • Optional Readonlyfree?: ((v: V) => void)

    If specified, this function will be called when a resource is disposed

      • (v): void
      • Parameters

        Returns void

  • Optional ReadonlyfullPolicy?: FullPolicy

    What to do if pool is full and a new resource allocation is requested. Default is error, throwing an error when pool is full.

  • Optional Readonlygenerate?: (() => V)

    If specified, this function will generate new resources as needed.

      • (): V
      • Returns V

  • Optional ReadonlyresourcesWithoutUserExpireAfterMs?: number

    If above 0, resources with no users will be automatically removed after this interval. Default: disabled

  • Optional ReadonlyuserExpireAfterMs?: number

    If above 0, users will be removed if there is no activity after this interval. Activity is marked whenever use us called with that user key. Default: disabled