Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement HTTP command dispatcher #19

Closed
RomanReznichenko opened this issue Apr 8, 2022 · 0 comments · Fixed by #20 or #39
Closed

Implement HTTP command dispatcher #19

RomanReznichenko opened this issue Apr 8, 2022 · 0 comments · Fixed by #20 or #39
Assignees
Labels
Type: enhancement New feature or request.

Comments

@RomanReznichenko
Copy link
Contributor

RomanReznichenko commented Apr 8, 2022

For direct synchronous communication (e.g. starting a scan, changing their settings, etc), we should provide a regular HTTP client as opposed to queues or pub/sub.

To send HTTP requests you can use the axios library. The configuration object might implement the following interface:

interface HttpCommandDispatcherConfig {
  baseUrl: string;
  token: string;
  rate?: { window: number; limit: number };
}

All rest parameters we should get from the command.

interface HttpOptions<T> {
  url: string;
  payload: T;
  method?: Method;
  expectReply?: boolean;
  ttl?: number;
  type?: string;
  correlationId?: string;
  params?: Record<string, unknown>;
  createdAt?: Date;
}

class HttpRequest<T, R> extends Command<T, R> {
  public readonly method: Method;
  public readonly url: string;
  public readonly params?: Record<string, unknown>;

  constructor(options: HttpOptions<T>) {
    super();
    // ...
  }
}
@derevnjuk derevnjuk added the Type: enhancement New feature or request. label Apr 8, 2022
@derevnjuk derevnjuk changed the title Implement http command dispatcher Implement HTTP command dispatcher Apr 12, 2022
pmstss pushed a commit that referenced this issue Apr 13, 2022
pmstss added a commit that referenced this issue Apr 18, 2022
derevnjuk pushed a commit that referenced this issue Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: enhancement New feature or request.
Projects
None yet
2 participants