Options
All
  • Public
  • Public/Protected
  • All
Menu

A Fluent Client. Connects to a FluentD server using the Forward protocol.

Hierarchy

  • FluentClient

Index

Constructors

constructor

  • Creates a new FluentClient

    Parameters

    • tag_prefix: null | string = null

      A prefix to prefix to all tags. For example, passing the prefix "foo" will cause emit("bar", data) to emit with foo.bar.

    • options: FluentClientOptions = {}

      The client options

    Returns FluentClient

Methods

socketOn

  • Attaches an event listener to the underlying socket

    See FluentSocketEvent for more info

    Parameters

    • event: FluentSocketEvent
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

emit

  • emit(data: EventRecord): Promise<void>
  • emit(data: EventRecord, timestamp: Timestamp): Promise<void>
  • emit(label: string, data: EventRecord): Promise<void>
  • emit(label: string, data: EventRecord, timestamp: Timestamp): Promise<void>
  • Emits an event to the Fluent Server

    Parameters

    • data: EventRecord

      The event to emit (required)

    Returns Promise<void>

    A Promise, which resolves when the event is successfully sent to the server. Enabling acknowledgements waits until the server indicates they have received the event.

  • Emits an event to the Fluent Server

    Parameters

    • data: EventRecord

      The event to emit (required)

    • timestamp: Timestamp

      A millisecond resolution timestamp to associate with the event (optional)

    Returns Promise<void>

    A Promise, which resolves when the event is successfully sent to the server. Enabling acknowledgements waits until the server indicates they have received the event.

  • Emits an event to the Fluent Server

    Parameters

    • label: string

      The label to emit the data with (optional)

    • data: EventRecord

      The event to emit (required)

    Returns Promise<void>

    A Promise, which resolves when the event is successfully sent to the server. Enabling acknowledgements waits until the server indicates they have received the event.

  • Emits an event to the Fluent Server

    Parameters

    • label: string

      The label to emit the data with (optional)

    • data: EventRecord

      The event to emit (required)

    • timestamp: Timestamp

      A millisecond resolution timestamp to associate with the event (optional)

    Returns Promise<void>

    A Promise, which resolves when the event is successfully sent to the server. Enabling acknowledgements waits until the server indicates they have received the event.

connect

  • connect(): Promise<void>
  • Connects the client. Can happen automatically during construction, but can be called after a disconnect() to resume the client.

    Returns Promise<void>

shutdown

  • shutdown(): Promise<void>
  • Closes the socket, and clears both the ackQueue and the sendQueue, rejecting all pending events.

    For use during shutdown events, where we don't plan on reconnecting

    Returns Promise<void>

disconnect

  • disconnect(): Promise<void>
  • Closes the socket and clears the ackQueue. Keeps pending events, which can be sent via a later .connect()

    Returns Promise<void>

syncFlush

  • syncFlush(): boolean
  • Flushes to the socket synchronously

    Prefer calling .flush which will flush on the next tick, allowing events from this tick to queue up.

    Returns boolean

    true if there are more events in the queue to flush, false otherwise

flush

  • flush(): Promise<boolean>
  • Flushes the event queue. Queues up the flushes for the next tick, preventing multiple flushes at the same time.

    Returns Promise<boolean>

    A promise, which resolves with a boolean indicating if there are more events to flush.

waitForPending

  • waitForPending(): Promise<void>
  • Waits for all currently pending events to successfully resolve or reject

    Returns Promise<void>

    A Promise which resolves once all the pending events have successfully been emitted

Accessors

sendQueueLength

  • get sendQueueLength(): number
  • Returns the number of queued events that haven't been sent yet

    Useful to react if we're queuing up too many events within a single tick

    Returns number

writable

  • get writable(): boolean
  • Returns whether or not the socket is writable

    Useful to react if we're disconnected for any reason

    Returns boolean

queueLength

  • get queueLength(): number
  • Returns the number of events that have been queued, but haven't resolved yet

    This includes acknowledgements and retries if enabled.

    Returns number

Legend

  • Constructor
  • Method
  • Protected method
  • Static method

Generated using TypeDoc