-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add durable functions for faster response time (#22)
* Add Durable Functions implementation * Fix docker compose
- Loading branch information
Showing
12 changed files
with
175 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/FunctionApp.Isolated/Functions/ImageSendOrchestration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.DurableTask; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace DiscordImagePoster.FunctionApp.Isolated.Functions; | ||
|
||
public static class ImageSendOrchestration | ||
{ | ||
|
||
[Function(nameof(ImageSendOrchestration))] | ||
public static async Task<string> RunAsync([OrchestrationTrigger] TaskOrchestrationContext context, string input) | ||
{ | ||
var logger = context.CreateReplaySafeLogger(nameof(ImageSendOrchestration)); | ||
logger.LogInformation("Starting image send orchestration."); | ||
|
||
return await context.CallActivityAsync<string>(nameof(SendRandomImageActivity), input); | ||
|
||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/FunctionApp.Isolated/Functions/SendRandomImageActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using DiscordImagePoster.Common.RandomizationService; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.DurableTask; | ||
using Microsoft.Extensions.Logging; | ||
|
||
public class SendRandomImageActivity | ||
{ | ||
private readonly ILogger<SendRandomImageActivity> _logger; | ||
private readonly IRandomImagePoster _randomImagePoster; | ||
|
||
public SendRandomImageActivity(ILogger<SendRandomImageActivity> logger, IRandomImagePoster randomImagePoster) | ||
{ | ||
_logger = logger; | ||
_randomImagePoster = randomImagePoster; | ||
} | ||
|
||
[Function(nameof(SendRandomImageActivity))] | ||
public async Task RunAsync([ActivityTrigger] string context) | ||
{ | ||
_logger.LogInformation("Sending random image triggered by orchestration."); | ||
await _randomImagePoster.PostRandomImageAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
{ | ||
"masterKey": { | ||
"name": "master", | ||
"value": "mock-secret-for-local-testing", | ||
"encrypted": false | ||
}, | ||
"functionKeys": [ | ||
{ | ||
"name": "default", | ||
"value": "mock-secret-for-local-testing", | ||
"encrypted": false | ||
} | ||
] | ||
{ | ||
"masterKey": { | ||
"name": "master", | ||
"value": "mock-secret-for-local-testing", | ||
"encrypted": false | ||
}, | ||
"functionKeys": [ | ||
{ | ||
"name": "default", | ||
"value": "mock-secret-for-local-testing", | ||
"encrypted": false | ||
} | ||
], | ||
"systemKeys": [ | ||
{ | ||
"name": "durabletask_extension", | ||
"value": "mock-secret-for-local-testing", | ||
"encrypted": false | ||
} | ||
], | ||
"hostName": "localhost:8080", | ||
"instanceId": "0000000000000000000000008156EC52", | ||
"source": "runtime", | ||
"decryptionKeyId": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"version": "2.0", | ||
"logging": { | ||
"applicationInsights": { | ||
"samplingSettings": { | ||
"isEnabled": true, | ||
"excludedTypes": "Request" | ||
}, | ||
"enableLiveMetricsFilters": true | ||
} | ||
"version": "2.0", | ||
"logging": { | ||
"applicationInsights": { | ||
"samplingSettings": { | ||
"isEnabled": true, | ||
"excludedTypes": "Request" | ||
}, | ||
"enableLiveMetricsFilters": true | ||
} | ||
} | ||
} | ||
} |