Skip to content

Commit

Permalink
Updates to BranchDto to speed up grace status; changed default time…
Browse files Browse the repository at this point in the history
…stamp on record creation; NuGet updates.
  • Loading branch information
ScottArbeit committed Jul 27, 2024
1 parent c6d7167 commit ad25fb0
Show file tree
Hide file tree
Showing 21 changed files with 514 additions and 556 deletions.
2 changes: 1 addition & 1 deletion src/CosmosSerializer/CosmosJsonSerializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.41.0" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.42.0-preview.0" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.42.0" />
</ItemGroup>

</Project>
158 changes: 97 additions & 61 deletions src/Grace.Actors/Branch.Actor.fs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/Grace.Actors/Grace.Actors.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.21.0" />
<PackageReference Include="Azure.Storage.Blobs.Batch" Version="12.18.0" />
<PackageReference Include="Azure.Storage.Common" Version="12.20.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.21.1" />
<PackageReference Include="Azure.Storage.Blobs.Batch" Version="12.18.1" />
<PackageReference Include="Azure.Storage.Common" Version="12.20.1" />
<PackageReference Include="Dapr.Actors" Version="1.13.1" />
<PackageReference Include="Dapr.Client" Version="1.13.1" />
<PackageReference Include="FSharpPlus" Version="1.6.1" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.42.0-preview.0" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.42.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0-preview.6.24327.7" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="NodaTime" Version="3.1.11" />
Expand Down
10 changes: 5 additions & 5 deletions src/Grace.Actors/Organization.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ module Organization =
/// Indicates that the actor is in an undefined state, and should be reset.
let mutable isDisposed = false

let updateDto (organizationEventType: OrganizationEventType) currentOrganizationDto =
let updateDto organizationEvent currentOrganizationDto =
let newOrganizationDto =
match organizationEventType with
match organizationEvent.Event with
| Created(organizationId, organizationName, ownerId) ->
{ OrganizationDto.Default with OrganizationId = organizationId; OrganizationName = organizationName; OwnerId = ownerId }
{ OrganizationDto.Default with OrganizationId = organizationId; OrganizationName = organizationName; OwnerId = ownerId; CreatedAt = organizationEvent.Metadata.Timestamp }
| NameSet(organizationName) -> { currentOrganizationDto with OrganizationName = organizationName }
| TypeSet(organizationType) -> { currentOrganizationDto with OrganizationType = organizationType }
| SearchVisibilitySet(searchVisibility) -> { currentOrganizationDto with SearchVisibility = searchVisibility }
Expand All @@ -60,7 +60,7 @@ module Organization =
| PhysicalDeleted -> currentOrganizationDto // Do nothing because it's about to be deleted anyway.
| Undeleted -> { currentOrganizationDto with DeletedAt = None; DeleteReason = String.Empty }

{ newOrganizationDto with UpdatedAt = Some(getCurrentInstant ()) }
{ newOrganizationDto with UpdatedAt = Some organizationEvent.Metadata.Timestamp }

member val private correlationId: CorrelationId = String.Empty with get, set

Expand Down Expand Up @@ -193,7 +193,7 @@ module Organization =
do! daprClient.PublishEventAsync(GracePubSubService, GraceEventStreamTopic, graceEvent)

// Update the Dto based on the current event.
organizationDto <- organizationDto |> updateDto organizationEvent.Event
organizationDto <- organizationDto |> updateDto organizationEvent

do! DefaultAsyncRetryPolicy.ExecuteAsync(fun () -> stateManager.SetStateAsync(dtoStateName, organizationDto))

Expand Down
8 changes: 4 additions & 4 deletions src/Grace.Actors/Owner.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ module Owner =

let updateDto ownerEvent currentOwnerDto =
let newOwnerDto =
match ownerEvent with
| Created(ownerId, ownerName) -> { OwnerDto.Default with OwnerId = ownerId; OwnerName = ownerName }
match ownerEvent.Event with
| Created(ownerId, ownerName) -> { OwnerDto.Default with OwnerId = ownerId; OwnerName = ownerName; CreatedAt = ownerEvent.Metadata.Timestamp }
| NameSet(ownerName) -> { currentOwnerDto with OwnerName = ownerName }
| TypeSet(ownerType) -> { currentOwnerDto with OwnerType = ownerType }
| SearchVisibilitySet(searchVisibility) -> { currentOwnerDto with SearchVisibility = searchVisibility }
Expand All @@ -60,7 +60,7 @@ module Owner =
| PhysicalDeleted -> currentOwnerDto // Do nothing because it's about to be deleted anyway.
| Undeleted -> { currentOwnerDto with DeletedAt = None; DeleteReason = String.Empty }

{ newOwnerDto with UpdatedAt = Some(getCurrentInstant ()) }
{ newOwnerDto with UpdatedAt = Some ownerEvent.Metadata.Timestamp }

member val private correlationId: CorrelationId = String.Empty with get, set

Expand Down Expand Up @@ -196,7 +196,7 @@ module Owner =

do! DefaultAsyncRetryPolicy.ExecuteAsync(fun () -> stateManager.SetStateAsync(eventsStateName, ownerEvents))

ownerDto <- ownerDto |> updateDto ownerEvent.Event
ownerDto <- ownerDto |> updateDto ownerEvent

do! DefaultAsyncRetryPolicy.ExecuteAsync(fun () -> stateManager.SetStateAsync(dtoStateName, ownerDto))

Expand Down
13 changes: 7 additions & 6 deletions src/Grace.Actors/Reference.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ module Reference =
/// Indicates that the actor is in an undefined state, and should be reset.
let mutable isDisposed = false
let updateDto referenceEventType currentReferenceDto =
let updateDto referenceEvent currentReferenceDto =
let newReferenceDto =
match referenceEventType with
match referenceEvent.Event with
| Created createdDto ->
{ currentReferenceDto with
ReferenceId = createdDto.ReferenceId
Expand All @@ -55,14 +55,15 @@ module Reference =
ReferenceType = createdDto.ReferenceType
ReferenceText = createdDto.ReferenceText
Links = createdDto.Links
CreatedAt = referenceEvent.Metadata.Timestamp
}
| LinkAdded link -> {currentReferenceDto with Links = currentReferenceDto.Links |> Array.append (Array.singleton link) |> Array.distinct }
| LinkRemoved link -> {currentReferenceDto with Links = currentReferenceDto.Links |> Array.except (Array.singleton link) }
| LogicalDeleted(force, deleteReason) -> {currentReferenceDto with DeletedAt = Some(getCurrentInstant()); DeleteReason = deleteReason}
| PhysicalDeleted -> currentReferenceDto // Do nothing because it's about to be deleted anyway.
| Undeleted -> {currentReferenceDto with DeletedAt = None; DeleteReason = String.Empty}

{newReferenceDto with UpdatedAt = Some(getCurrentInstant())}
{newReferenceDto with UpdatedAt = Some referenceEvent.Metadata.Timestamp}

member val private correlationId: CorrelationId = String.Empty with get, set

Expand All @@ -79,7 +80,7 @@ module Reference =
referenceEvents.AddRange(retrievedEvents)

// Apply all events to the state.
referenceDto <- retrievedEvents |> Seq.fold (fun referenceDto referenceEvent -> referenceDto |> updateDto referenceEvent.Event) ReferenceDto.Default
referenceDto <- retrievedEvents |> Seq.fold (fun referenceDto referenceEvent -> referenceDto |> updateDto referenceEvent) ReferenceDto.Default

message <- "Retrieved from database"
| None -> message <- "Not found in database"
Expand Down Expand Up @@ -166,7 +167,7 @@ module Reference =
do! Storage.SaveState stateManager eventsStateName referenceEvents

// Update the referenceDto with the event.
referenceDto <- referenceDto |> updateDto referenceEvent.Event
referenceDto <- referenceDto |> updateDto referenceEvent

// Publish the event to the rest of the world.
let graceEvent = Events.GraceEvent.ReferenceEvent referenceEvent
Expand Down Expand Up @@ -268,7 +269,7 @@ module Reference =
do! Storage.SaveState stateManager eventsStateName referenceEvents

// Update the referenceDto with the event.
referenceDto <- referenceDto |> updateDto referenceEvent.Event
referenceDto <- referenceDto |> updateDto referenceEvent

// Publish the event to the rest of the world.
let graceEvent = Events.GraceEvent.ReferenceEvent referenceEvent
Expand Down
6 changes: 4 additions & 2 deletions src/Grace.Actors/Repository.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ module Repository =
OrganizationId = organizationId
ObjectStorageProvider = Constants.DefaultObjectStorageProvider
StorageAccountName = Constants.DefaultObjectStorageAccount
StorageContainerName = StorageContainerName Constants.DefaultObjectStorageContainerName }
StorageContainerName = StorageContainerName Constants.DefaultObjectStorageContainerName
CreatedAt = repositoryEvent.Metadata.Timestamp
}
| Initialized -> { currentRepositoryDto with InitializedAt = Some(getCurrentInstant ()) }
| ObjectStorageProviderSet objectStorageProvider -> { currentRepositoryDto with ObjectStorageProvider = objectStorageProvider }
| StorageAccountNameSet storageAccountName -> { currentRepositoryDto with StorageAccountName = storageAccountName }
Expand All @@ -179,7 +181,7 @@ module Repository =
| PhysicalDeleted -> currentRepositoryDto // Do nothing because it's about to be deleted anyway.
| Undeleted -> { currentRepositoryDto with DeletedAt = None; DeleteReason = String.Empty }

{ newRepositoryDto with UpdatedAt = Some(getCurrentInstant ()) }
{ newRepositoryDto with UpdatedAt = Some repositoryEvent.Metadata.Timestamp }

// This is essentially an object-oriented implementation of the Lazy<T> pattern. I was having issues with Lazy<T>,
// and after a solid day wrestling with it, I dropped it and did this. Works a treat.
Expand Down
2 changes: 1 addition & 1 deletion src/Grace.Actors/Services.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ module Services =

let referenceActorProxy = actorProxyFactory.CreateActorProxy<IReferenceActor>(referenceActorId, ActorName.Reference)

let! referenceDto = referenceActorProxy.Get correlationId
let! referenceDto = referenceActorProxy.Get (correlationId + " (getRootDirectoryByReferenceId)")

return! getRootDirectoryBySha256Hash repositoryId referenceDto.Sha256Hash correlationId
}
Expand Down
12 changes: 6 additions & 6 deletions src/Grace.Aspire.AppHost/Grace.Aspire.AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Azure.Security.KeyVault" Version="8.0.2" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.2" />
<PackageReference Include="Aspire.Azure.Security.KeyVault" Version="8.1.0" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.1.0" />
<PackageReference Include="Aspire.Hosting" Version="9.0.0-preview.3.24210.17" />
<PackageReference Include="Aspire.Hosting.Azure" Version="8.0.2" />
<PackageReference Include="Aspire.Hosting.Dapr" Version="8.0.2" />
<PackageReference Include="Aspire.Hosting.Redis" Version="8.0.2" />
<PackageReference Include="Aspire.Microsoft.Azure.Cosmos" Version="8.0.2" />
<PackageReference Include="Aspire.Hosting.Azure" Version="8.1.0" />
<PackageReference Include="Aspire.Hosting.Dapr" Version="8.1.0" />
<PackageReference Include="Aspire.Hosting.Redis" Version="8.1.0" />
<PackageReference Include="Aspire.Microsoft.Azure.Cosmos" Version="8.1.0" />
<PackageReference Include="Azure.Identity" Version="1.12.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.0.0-preview.6.24353.1" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.1.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
Expand Down
Loading

0 comments on commit ad25fb0

Please sign in to comment.