Options
All
  • Public
  • Public/Protected
  • All
Menu

@imqueue/core

Index

Type aliases

AllowedTimeFormat

AllowedTimeFormat: "microseconds" | "milliseconds" | "seconds"

Variables

Const IMQ_LOG_ARGS

IMQ_LOG_ARGS: boolean = !!process.env['IMQ_LOG_ARGS']

Environment variable IMQ_LOG_ARGS=[1, 0] - enables/disables profiled call arguments to be logged

type

{boolean}

Const IMQ_LOG_TIME

IMQ_LOG_TIME: boolean = !!process.env['IMQ_LOG_TIME']

Environment variable IMQ_LOG_TIME=[1, 0] - enables/disables profiled timings logging

type

{boolean}

Const IMQ_LOG_TIME_FORMAT

IMQ_LOG_TIME_FORMAT: AllowedTimeFormat = process.env['IMQ_LOG_TIME_FORMAT'] as AllowedTimeFormat || 'microseconds'

Environment variable IMQ_LOG_TIME_FORMAT=[ 'microseconds', 'milliseconds', 'seconds' ]. Specifies profiled time logging format, by default is 'microseconds'

type

{AllowedTimeFormat | string}

Const RX_CLIENT_CLEAN

RX_CLIENT_CLEAN: RegExp = /:(reader|writer|watcher).*$/

Const RX_CLIENT_NAME

RX_CLIENT_NAME: RegExp = /name=(\S+)/g

Const RX_CLIENT_TEST

RX_CLIENT_TEST: RegExp = /:(reader|writer|watcher)/

Const commands

commands: string[] = [...new Set<string>(require('redis-commands').list.map((name: string) => name.toLowerCase()))].filter((name: string) => name !== 'stream')

Const lookupTable

lookupTable: string[] = []

Const rand

rand: any = Math.random.bind(Math)

Functions

buildOptions

  • buildOptions<T>(defaultOptions: T, givenOptions?: Partial<T>): T
  • Safely builds full options definition using default options and partial given options

    Type parameters

    • T

    Parameters

    • defaultOptions: T
    • Optional givenOptions: Partial<T>

    Returns T

intrand

  • intrand(min: number, max: number): number
  • Returns random integer between given min and max

    Parameters

    • min: number
    • max: number

    Returns number

logDebugInfo

  • logDebugInfo(__namedParameters: object): void
  • Prints debug information

    Parameters

    • __namedParameters: object
      • args: any[]
      • className: string
      • debugArgs: boolean
      • debugTime: boolean
      • logger: ILogger
      • methodName: string
      • start: number

    Returns void

makeCallback

  • makeCallback(resolve: function, reject: function): function
  • Makes a callback function able to resolve or reject with given resolve and reject functions

    Parameters

    • resolve: function
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • reject: function
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns function

      • (...args: any[]): any
      • Parameters

        • Rest ...args: any[]

        Returns any

makePromised

  • makePromised(method: function): asyncMethod
  • Makes given method promised

    access

    private

    Parameters

    • method: function
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns asyncMethod

pack

  • pack(data: any): string
  • Compress given data and returns binary string

    Parameters

    • data: any

    Returns string

profile

  • profile(enableDebugTime?: undefined | false | true, enableDebugArgs?: undefined | false | true): wrapper
  • Implements '@profile' decorator.

    example
    import { profile } from '@imqueue/core';
    
    class MyClass {
    
        @profile(true) // forced profiling
        public myMethod() {
            // ...
        }
    
        @profile() // profiling happened only depending on env DEBUG flag
        private innerMethod() {
            // ...
        }
    }

    Parameters

    • Optional enableDebugTime: undefined | false | true
    • Optional enableDebugArgs: undefined | false | true

    Returns wrapper

    {( target: any, methodName: (string), descriptor: TypedPropertyDescriptor<(...args: any[]) => any> ) => void}

promisify

  • promisify(obj: any, restrict?: string[]): void
  • Makes given object methods promise-like

    Parameters

    • obj: any

      source object to modify

    • Optional restrict: string[]

      stick promise-like behavior to a given restricted list of methods

    Returns void

propertiesOf

  • propertiesOf(obj: any): string[]
  • Returns entire list of the given object properties including entire prototype chain

    Parameters

    • obj: any

    Returns string[]

sha1

  • sha1(str: string): string
  • Returns SHA1 hash sum of the given string

    Parameters

    • str: string

    Returns string

unpack

  • unpack(data: string): any
  • Decompress binary string and returns plain data

    Parameters

    • data: string

    Returns any

uuid

  • uuid(): string
  • Generates and returns Unified Unique Identifier

    Returns string

Object literals

Const DEFAULT_IMQ_OPTIONS

DEFAULT_IMQ_OPTIONS: object

cleanup

cleanup: false = false

cleanupFilter

cleanupFilter: string = "*"

host

host: string = "localhost"

logger

logger: Console = console

port

port: number = 6379

prefix

prefix: string = "imq"

safeDelivery

safeDelivery: false = false

safeDeliveryTtl

safeDeliveryTtl: number = 5000

useGzip

useGzip: false = false

watcherCheckDelay

watcherCheckDelay: number = 5000