Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Events todo #1880

Merged
merged 7 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ApiService/ApiService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static List<ILog> GetLoggers(IServiceConfig config) {
return loggers;
}


//Move out expensive resources into separate class, and add those as Singleton
// ArmClient, Table Client(s), Queue Client(s), HttpClient, etc.
public static void Main() {
Expand Down
14 changes: 10 additions & 4 deletions src/ApiService/ApiService/onefuzzlib/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ public interface IEvents {
public class Events : IEvents {
private readonly IQueue _queue;
private readonly IWebhookOperations _webhook;
private ILogTracer _log;
private readonly ILogTracer _log;
private readonly IContainers _containers;
private readonly ICreds _creds;

public Events(IQueue queue, IWebhookOperations webhook, ILogTracer log) {
public Events(IQueue queue, IWebhookOperations webhook, ILogTracer log, IContainers containers, ICreds creds) {
_queue = queue;
_webhook = webhook;
_log = log;
_containers = containers;
_creds = creds;
}

public async Async.Task QueueSignalrEvent(EventMessage eventMessage) {
Expand All @@ -37,12 +41,14 @@ public async Async.Task QueueSignalrEvent(EventMessage eventMessage) {
public async Async.Task SendEvent(BaseEvent anEvent) {
var eventType = anEvent.GetEventType();

var instanceId = await _containers.GetInstanceId();

var eventMessage = new EventMessage(
Guid.NewGuid(),
eventType,
anEvent,
Guid.NewGuid(), // todo
"test" //todo
instanceId,
_creds.GetInstanceName()
);
await QueueSignalrEvent(eventMessage);
await _webhook.SendEvent(eventMessage);
Expand Down