Options
All
  • Public
  • Public/Protected
  • All
Menu

A factory service that allows the client to generate Deadline objects based on different strategies.

The main issue is that sometimes the local computer time is not in sync, the created deadlines may be too old or too in the future and rejected by the server.

Hierarchy

  • DeadlineService

Index

Constructors

Private constructor

  • Private constructor, use the create static method

    Parameters

    • repositoryFactory: RepositoryFactory

      the repository factory to call the rest servers.

    • epochAdjustment: number

      the server epochAdjustment

    • serverTime: number

      the latest known server time to calculate the remote and local time difference.

    Returns DeadlineService

Properties

Private localTimeOffset

localTimeOffset: number

The difference in milliseconds between the server and the local time. It used to create "server" deadline without asking for the server time every time a new deadline is created.

Methods

createDeadlineUsingLocalTime

  • createDeadlineUsingLocalTime(deadline?: number, chronoUnit?: ChronoUnit): Deadline
  • It creates a deadline using the local time. If the local system time is not in sync, the Deadline may be rejected by the server.

    Parameters

    • deadline: number = ...

      the deadline value

    • chronoUnit: ChronoUnit = ...

      the unit of the value.

    Returns Deadline

createDeadlineUsingOffset

  • createDeadlineUsingOffset(deadline?: number, chronoUnit?: ChronoUnit): Deadline
  • It creates a deadline using the known difference between the local and server time.

    Parameters

    • deadline: number = ...

      the deadline value

    • chronoUnit: ChronoUnit = ...

      the unit of the value.

    Returns Deadline

createDeadlineUsingServerTime

  • createDeadlineUsingServerTime(deadline?: number, chronoUnit?: ChronoUnit): Promise<Deadline>
  • It creates a deadline by querying the current time to the server each time. This is the most accurate but less efficient way.

    Parameters

    • deadline: number = ...

      the deadline value

    • chronoUnit: ChronoUnit = ...

      the unit of the value.

    Returns Promise<Deadline>

Static create

Generated using TypeDoc