Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Farrell xximjasonxx

View GitHub Profile
View cluster.json
{
"rabbitMq": {
"host": "rabbitmq-release.rabbitmq",
"port": 5672
}
}
View program.cs
Host.CreateDefaultBuilder()
.ConfigureAppConfiguration((_, builder) =>
builder.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false)
.AddJsonFile($"appsettings.{System.Environment.GetEnvironmentVariable("ENV")}.json", optional: true)
.Build())
View appsettings.json
{
"rabbitMq": {
"host": "localhost",
"port": 8500,
"user": "admin",
"password": "Password01!",
"channelName": "stock_write"
}
}
View app.cs
namespace StockPriceWriter
{
public class Application
{
private readonly IGetStockService _getStockService;
private readonly IPublishService _publishService;
public Application(IGetStockService getStockService, IPublishService publishService)
{
_getStockService = getStockService;
View cleanup.cs
[FunctionName("Cleanup_DurableFunctionInstances")]
public async Task Cleanup_DurableFunctionInstances(
[QueueTrigger(Constants.QUEUE_DURABLE_FUNCTION_CLEANUP, Connection = Constants.TABLE_STORAGE_CONNECTION)] string instanceId,
[DurableClient] IDurableOrchestrationClient client,
ILogger logger)
{
try
{
var result = await client.PurgeInstanceHistoryAsync(instanceId);
if (result?.InstancesDeleted > 0)
View orchestrator.cs
[FunctionName("Orchestrate_Indexing")]
public async Task OrchestrateIndexing(
[OrchestrationTrigger] IDurableOrchestrationContext context,
[Queue(Constants.QUEUE_NOTIFYFOLLOWERS, Connection = Constants.TABLE_STORAGE_CONNECTION)] ICollector<string> eventCollector,
[Queue("durable-function-task-end", Connection = Constants.TABLE_STORAGE_CONNECTION)] ICollector<string> cleanupCollector,
ILogger logger)
{
var channelId = context.GetInput<IndexChannelInput>().ChannelId;
try
{
View durable.cs
[FunctionName("IndexChannel")]
public async Task IndexChannel(
[QueueTrigger(Constants.QUEUE_CLIPSINDEX, Connection = Constants.TABLE_STORAGE_CONNECTION)] string channelId,
[DurableClient] IDurableOrchestrationClient starter,
ILogger logger)
{
// are we already indexing?
var status = await starter.GetStatusAsync($"{channelId}-index");
if (status == null)
{
View stockpricewriter.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: price-writer-job
namespace: stock-app
spec:
schedule: "*/2 * * * *"
successfulJobsHistoryLimit: 0
failedJobsHistoryLimit: 0
jobTemplate:
View service.yaml
apiVersion: v1
kind: Service
metadata:
name: svc-sayhelloapi
namespace: ns-sayhelloapi-dev
spec:
selector:
app: sayhelloapi
ports:
- protocol: TCP
View deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: sayhelloapi-deployment
namespace: ns-sayhelloapi-dev
spec:
replicas: 3
selector:
matchLabels:
app: sayhelloapi