This file contains hidden or 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
| public class OrderStateMachine : MassTransitStateMachine<OrderState> | |
| { | |
| public State PaymentProcessing { get; private set; } | |
| public State PaymentProcessingFailed { get; private set; } | |
| public State Shipping { get; private set; } | |
| public State ShippingFailed { get; private set; } | |
| public Event<OrderSubmitted> OrderSubmitted { get; private set; } |
This file contains hidden or 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
| builder.Services.AddMassTransit(busConfigurator => | |
| { | |
| ConnectionFactory.DefaultAddressFamily = AddressFamily.InterNetwork; | |
| busConfigurator | |
| .AddSagaStateMachine<OrderStateMachine, OrderState>() | |
| .Endpoint(_ => _.AddConfigureEndpointCallback((context, cfg) => | |
| { | |
| cfg.UseMessageRetry(_ => _.Immediate(1)); | |
| cfg.UseInMemoryInboxOutbox(context); |
This file contains hidden or 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
| app.MapGet("/submitOrder", async ([FromServices] IPublishEndpoint publishEndpoint) => | |
| { | |
| await publishEndpoint.Publish(new OrderSubmitted | |
| { | |
| OrderId = NewId.NextGuid(), | |
| }); | |
| return; | |
| }); |
This file contains hidden or 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
| apiVersion: keda.sh/v1alpha1 | |
| kind: ScaledObject | |
| metadata: | |
| name: consumer-scaledobject | |
| namespace: default | |
| spec: | |
| scaleTargetRef: | |
| name: consumer | |
| minReplicaCount: 0 | |
| maxReplicaCount: 3 |
This file contains hidden or 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
| app.MapGet("/submitOrders-parallel/{messageCount:int}", async ( | |
| [FromRoute] int messageCount, | |
| [FromServices] IPublishEndpoint publishEndpoint) => | |
| { | |
| var messages = Enumerable.Range(0, messageCount) | |
| .Select(_ => publishEndpoint.Publish(new OrderSubmitted | |
| { | |
| OrderId = NewId.NextGuid(), | |
| }) | |
| ); |
This file contains hidden or 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 stage is used when running from VS in fast mode (Default for Debug configuration) | |
| FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base | |
| USER $APP_UID | |
| WORKDIR /app | |
| EXPOSE 8080 | |
| EXPOSE 8081 | |
| # This stage is used to build the service project | |
| FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build |
This file contains hidden or 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
| pipelines: | |
| default: | |
| - step: | |
| runs-on: | |
| - self.hosted | |
| - linux | |
| script: |
This file contains hidden or 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
| error = Setpoint - current_value; | |
| % PID calculations | |
| proportional = P * error; | |
| integral = integral + (I * error * dt); | |
| derivative = D * (error - previous_error) / dt; |
This file contains hidden or 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
| // Build Semantic Kernel with OpenAI chat completion | |
| var builder = Kernel.CreateBuilder(); | |
| builder.AddOpenAIChatCompletion("gpt-5-nano", apiKey); | |
| var kernel = builder.Build(); | |
| var chatCompletion = _kernel.GetRequiredService<IChatCompletionService>(); | |
| // Initialize chat history with system prompt | |
| var chatHistory = new ChatHistory(); | |
| chatHistory.AddSystemMessage(PromtsHelper.GetSystemPrompt()); |
OlderNewer