Skip to content

Commit

Permalink
Merge branch 'main' into chore/add-redis-postgres-health-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
arealmaas authored Sep 20, 2024
2 parents 42326d1 + c2559d8 commit a275c12
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 12 deletions.
1 change: 1 addition & 0 deletions .azure/applications/graphql/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ module containerApp '../../modules/containerApp/main.bicep' = {
apimIp: apimIp
tags: tags
resources: resources
revisionSuffix: imageTag
}
}

Expand Down
1 change: 1 addition & 0 deletions .azure/applications/web-api-eu/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ module containerApp '../../modules/containerApp/main.bicep' = {
apimIp: apimIp
tags: tags
resources: resources
revisionSuffix: imageTag
}
}

Expand Down
1 change: 1 addition & 0 deletions .azure/applications/web-api-so/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ module containerApp '../../modules/containerApp/main.bicep' = {
apimIp: apimIp
tags: tags
resources: resources
revisionSuffix: imageTag
}
}

Expand Down
7 changes: 7 additions & 0 deletions .azure/modules/containerApp/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ param tags object
@description('CPU and memory resources for the container app')
param resources object?

@description('The suffix for the revision of the container app')
param revisionSuffix string

// Container app revision name does not allow '.' character
var cleanedRevisionSuffix = replace(revisionSuffix, '.', '-')

var probes = [
{
periodSeconds: 5
Expand Down Expand Up @@ -75,6 +81,7 @@ resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
}
environmentId: containerAppEnvId
template: {
revisionSuffix: cleanedRevisionSuffix
scale: {
minReplicas: 1
maxReplicas: 1 // temp disable scaling for outbox scheduling
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/action-check-for-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
- '.github/**/*'
- 'src/**/*'
- '.azure/applications/**/*'
- '.azure/modules/containerApp/**/*'
tests:
- 'tests/**/*'
azure:
Expand Down
12 changes: 9 additions & 3 deletions docs/schema/V1/schema.verified.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ type DialogByIdPayload {
errors: [DialogByIdError!]!
}

type DialogUpdatedPayload {
type DialogEventPayload {
id: UUID!
type: DialogEventType!
}

type GuiAction {
Expand Down Expand Up @@ -211,7 +212,7 @@ type SeenLog {
}

type Subscriptions @authorize(policy: "enduser") {
dialogUpdated(dialogId: UUID!): DialogUpdatedPayload!
dialogEvents(dialogId: UUID!): DialogEventPayload!
}

type Transmission {
Expand Down Expand Up @@ -296,6 +297,11 @@ enum AttachmentUrlConsumer {
API
}

enum DialogEventType {
DIALOG_UPDATED
DIALOG_DELETED
}

enum DialogStatus {
"The dialogue is considered new. Typically used for simple messages that do not require any interaction, or as an initial step for dialogues. This is the default."
NEW
Expand Down Expand Up @@ -355,4 +361,4 @@ scalar DateTime @specifiedBy(url: "https:\/\/www.graphql-scalars.com\/date-time"

scalar URL @specifiedBy(url: "https:\/\/tools.ietf.org\/html\/rfc3986")

scalar UUID @specifiedBy(url: "https:\/\/tools.ietf.org\/html\/rfc4122")
scalar UUID @specifiedBy(url: "https:\/\/tools.ietf.org\/html\/rfc4122")
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,14 @@ public enum AttachmentUrlConsumer
Api = 2
}

public sealed class DialogUpdatedPayload
public sealed class DialogEventPayload
{
public Guid Id { get; set; }
public DialogEventType Type { get; set; }
}

public enum DialogEventType
{
DialogUpdated = 1,
DialogDeleted = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ namespace Digdir.Domain.Dialogporten.GraphQL.EndUser.DialogById;
public sealed class Subscriptions
{
[Subscribe]
[Topic($"{Constants.DialogUpdatedTopic}{{{nameof(dialogId)}}}")]
public DialogUpdatedPayload DialogUpdated(Guid dialogId,
[EventMessage] Guid eventMessage)
[Topic($"{Constants.DialogEventsTopic}{{{nameof(dialogId)}}}")]
public DialogEventPayload DialogEvents(Guid dialogId,
[EventMessage] DialogEventPayload eventMessage)
{
ArgumentNullException.ThrowIfNull(dialogId);
ArgumentNullException.ThrowIfNull(eventMessage);
return new DialogUpdatedPayload { Id = dialogId };
return eventMessage;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Digdir.Domain.Dialogporten.Application.Common;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Events;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Events.Activities;
using Digdir.Domain.Dialogporten.Domain.Outboxes;
using Digdir.Domain.Dialogporten.Infrastructure.GraphQl;
using Digdir.Library.Entity.Abstractions.Features.EventPublisher;
using HotChocolate.Subscriptions;
using Microsoft.EntityFrameworkCore.Diagnostics;
Expand Down Expand Up @@ -72,8 +74,28 @@ public override async ValueTask<int> SavedChangesAsync(SaveChangesCompletedEvent
var task = domainEvent switch
{
DialogUpdatedDomainEvent dialogUpdatedDomainEvent => _topicEventSender.SendAsync(
$"{Constants.DialogUpdatedTopic}{dialogUpdatedDomainEvent.DialogId}",
dialogUpdatedDomainEvent.DialogId,
$"{Constants.DialogEventsTopic}{dialogUpdatedDomainEvent.DialogId}",
new DialogEventPayload
{
Id = dialogUpdatedDomainEvent.DialogId,
Type = DialogEventType.DialogUpdated
},
cancellationToken),
DialogDeletedDomainEvent dialogDeletedDomainEvent => _topicEventSender.SendAsync(
$"{Constants.DialogEventsTopic}{dialogDeletedDomainEvent.DialogId}",
new DialogEventPayload
{
Id = dialogDeletedDomainEvent.DialogId,
Type = DialogEventType.DialogDeleted
},
cancellationToken),
DialogActivityCreatedDomainEvent dialogActivityCreatedDomainEvent => _topicEventSender.SendAsync(
$"{Constants.DialogEventsTopic}{dialogActivityCreatedDomainEvent.DialogId}",
new DialogEventPayload
{
Id = dialogActivityCreatedDomainEvent.DialogId,
Type = DialogEventType.DialogUpdated
},
cancellationToken),
_ => ValueTask.CompletedTask
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Digdir.Domain.Dialogporten.Infrastructure.GraphQl;

internal struct DialogEventPayload
{
public Guid Id { get; set; }
public DialogEventType Type { get; set; }
}

internal enum DialogEventType
{
DialogUpdated = 1,
DialogDeleted = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ namespace Digdir.Domain.Dialogporten.Infrastructure.GraphQl;
public static class GraphQlSubscriptionConstants
{
public const string SubscriptionTopicPrefix = "graphql_subscriptions_";
public const string DialogUpdatedTopic = "dialogUpdated/";
public const string DialogEventsTopic = "dialogEvents/";
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void All_Classes_In_Infrastructure_Should_Be_Internal()
{
nameof(InfrastructureAssemblyMarker),
nameof(InfrastructureExtensions),

// These classes are currently public, but should be internal, moved to another assembly, or deleted
nameof(OutboxScheduler),
nameof(IUpstreamServiceError)
Expand Down

0 comments on commit a275c12

Please sign in to comment.