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

Commit

Permalink
rename type alias Tasks to Async
Browse files Browse the repository at this point in the history
  • Loading branch information
chkeita committed Apr 11, 2022
1 parent 3382d3b commit d891a02
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// to avoid collision with Task in model.cs
global using Tasks = System.Threading.Tasks;
global using Async = System.Threading.Tasks;

using System;
using System.Collections.Generic;
Expand Down
8 changes: 4 additions & 4 deletions src/ApiService/ApiService/QueueFileChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public QueueFileChanges(ILoggerFactory loggerFactory, IStorageProvider storagePr
}

[Function("QueueFileChanges")]
public Tasks.Task Run(
public Async.Task Run(
[QueueTrigger("file-changes-refactored", Connection = "AzureWebJobsStorage")] string msg,
int dequeueCount)
{
Expand All @@ -41,18 +41,18 @@ public Tasks.Task Run(
if (!fileChangeEvent.ContainsKey(eventType)
|| fileChangeEvent[eventType] != "Microsoft.Storage.BlobCreated")
{
return Tasks.Task.CompletedTask;
return Async.Task.CompletedTask;
}

const string topic = "topic";
if (!fileChangeEvent.ContainsKey(topic)
|| !_storage.CorpusAccounts().Contains(fileChangeEvent[topic]))
{
return Tasks.Task.CompletedTask;
return Async.Task.CompletedTask;
}

file_added(fileChangeEvent, lastTry);
return Tasks.Task.CompletedTask;
return Async.Task.CompletedTask;
}

private void file_added(Dictionary<string, string> fileChangeEvent, bool failTaskOnTransientError)
Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/QueueNodeHearbeat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public QueueNodeHearbeat(ILoggerFactory loggerFactory, INodeOperations nodes, IE
}

[Function("QueueNodeHearbeat")]
public async Tasks.Task Run([QueueTrigger("myqueue-items", Connection = "AzureWebJobsStorage")] string msg)
public async Async.Task Run([QueueTrigger("myqueue-items", Connection = "AzureWebJobsStorage")] string msg)
{
_logger.LogInformation($"heartbeat: {msg}");

Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/QueueTaskHearbeat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public QueueTaskHearbeat(ILoggerFactory loggerFactory, ITaskOperations tasks, IE
}

[Function("QueueNodeHearbeat")]
public async Tasks.Task Run([QueueTrigger("myqueue-items2", Connection = "AzureWebJobsStorage")] string msg)
public async Async.Task Run([QueueTrigger("myqueue-items2", Connection = "AzureWebJobsStorage")] string msg)
{
_logger.LogInformation($"heartbeat: {msg}");

Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/UserCredentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class UserCredentials

static Task<OneFuzzResult<string[]>> GetAllowedTenants()
{
return Tasks.Task.FromResult(OneFuzzResult<string[]>.Ok(Array.Empty<string>()));
return Async.Task.FromResult(OneFuzzResult<string[]>.Ok(Array.Empty<string>()));
}

/*
Expand Down
8 changes: 4 additions & 4 deletions src/ApiService/ApiService/onefuzzlib/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ List<EventMessage> arguments

public interface IEvents
{
public Tasks.Task SendEvent(BaseEvent anEvent);
public Async.Task SendEvent(BaseEvent anEvent);

public Tasks.Task QueueSignalrEvent(EventMessage message);
public Async.Task QueueSignalrEvent(EventMessage message);
}

public class Events : IEvents
Expand All @@ -38,14 +38,14 @@ public Events(IQueue queue, ILoggerFactory loggerFactory, IWebhookOperations web
_webhook = webhook;
}

public async Tasks.Task QueueSignalrEvent(EventMessage eventMessage)
public async Async.Task QueueSignalrEvent(EventMessage eventMessage)
{
var message = new SignalREvent("events", new List<EventMessage>() { eventMessage });
var encodedMessage = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(message));
await _queue.SendMessage("signalr-events", encodedMessage, StorageType.Config);
}

public async Tasks.Task SendEvent(BaseEvent anEvent)
public async Async.Task SendEvent(BaseEvent anEvent)
{
var eventType = anEvent.GetEventType();

Expand Down
6 changes: 3 additions & 3 deletions src/ApiService/ApiService/onefuzzlib/Queue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace Microsoft.OneFuzz.Service;
public interface IQueue
{
Tasks.Task SendMessage(string name, byte[] message, StorageType storageType, TimeSpan? visibilityTimeout = null, TimeSpan? timeToLive = null);
Tasks.Task<bool> QueueObject<T>(string name, T obj, StorageType storageType, TimeSpan? visibilityTimeout);
Async.Task SendMessage(string name, byte[] message, StorageType storageType, TimeSpan? visibilityTimeout = null, TimeSpan? timeToLive = null);
Async.Task<bool> QueueObject<T>(string name, T obj, StorageType storageType, TimeSpan? visibilityTimeout);
}


Expand All @@ -26,7 +26,7 @@ public Queue(IStorage storage, ILoggerFactory loggerFactory)
}


public async Tasks.Task SendMessage(string name, byte[] message, StorageType storageType, TimeSpan? visibilityTimeout = null, TimeSpan? timeToLive = null)
public async Async.Task SendMessage(string name, byte[] message, StorageType storageType, TimeSpan? visibilityTimeout = null, TimeSpan? timeToLive = null)
{
var queue = GetQueue(name, storageType);
if (queue != null)
Expand Down
4 changes: 2 additions & 2 deletions src/ApiService/ApiService/onefuzzlib/TaskOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Microsoft.OneFuzz.Service;

public interface ITaskOperations : IOrm<Task>
{
Tasks.Task<Task?> GetByTaskId(Guid taskId);
Async.Task<Task?> GetByTaskId(Guid taskId);
}

public class TaskOperations : Orm<Task>, ITaskOperations
Expand All @@ -18,7 +18,7 @@ public TaskOperations(IStorage storage)

}

public async Tasks.Task<Task?> GetByTaskId(Guid taskId)
public async Async.Task<Task?> GetByTaskId(Guid taskId)
{
var data = QueryAsync(filter: $"RowKey eq '{taskId}'");

Expand Down
8 changes: 4 additions & 4 deletions src/ApiService/ApiService/onefuzzlib/WebhookOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public WebhookMessageLogOperations(IStorage storage, IQueue queue, ILoggerFactor
}


public async Tasks.Task QueueWebhook(WebhookMessageLog webhookLog)
public async Async.Task QueueWebhook(WebhookMessageLog webhookLog)
{
var obj = new WebhookMessageQueueObj(webhookLog.WebhookId, webhookLog.EventId);

Expand Down Expand Up @@ -61,7 +61,7 @@ private void QueueObject(string v, WebhookMessageQueueObj obj, StorageType confi

public interface IWebhookOperations
{
Tasks.Task SendEvent(EventMessage eventMessage);
Async.Task SendEvent(EventMessage eventMessage);
}

public class WebhookOperations : Orm<Webhook>, IWebhookOperations
Expand All @@ -73,7 +73,7 @@ public WebhookOperations(IStorage storage, IWebhookMessageLogOperations webhookM
_webhookMessageLogOperations = webhookMessageLogOperations;
}

async public Tasks.Task SendEvent(EventMessage eventMessage)
async public Async.Task SendEvent(EventMessage eventMessage)
{
await foreach (var webhook in GetWebhooksCached())
{
Expand All @@ -85,7 +85,7 @@ async public Tasks.Task SendEvent(EventMessage eventMessage)
}
}

async private Tasks.Task AddEvent(Webhook webhook, EventMessage eventMessage)
async private Async.Task AddEvent(Webhook webhook, EventMessage eventMessage)
{
var message = new WebhookMessageLog(
EventId: eventMessage.EventId,
Expand Down

0 comments on commit d891a02

Please sign in to comment.