Skip to content

Commit

Permalink
Fixes for the Reference rearchitecture work.
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottArbeit committed Jul 23, 2024
1 parent 7dfc371 commit 5962f7d
Show file tree
Hide file tree
Showing 32 changed files with 393 additions and 446 deletions.
46 changes: 0 additions & 46 deletions src/.grace/graceconfig.json

This file was deleted.

29 changes: 0 additions & 29 deletions src/.grace/graceignore.txt

This file was deleted.

4 changes: 2 additions & 2 deletions src/CosmosSerializer/CosmosJsonSerializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.40.0" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.41.0" />
<PackageReference Include="Azure.Core" Version="1.41.0" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.42.0-preview.0" />
</ItemGroup>

</Project>
89 changes: 59 additions & 30 deletions src/Grace.Actors/Branch.Actor.fs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Grace.Actors/Commands.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ module Commands =
[<KnownType("GetKnownTypes")>]
type ReferenceCommand =
| Create of referenceDto: ReferenceDto
| AddLink of link: ReferenceLinkType
| RemoveLink of link: ReferenceLinkType
| DeleteLogical of force: bool * DeleteReason: DeleteReason
| DeletePhysical
| Undelete
Expand Down
2 changes: 2 additions & 0 deletions src/Grace.Actors/Events.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ module Events =
[<KnownType("GetKnownTypes")>]
type ReferenceEventType =
| Created of referenceDto: ReferenceDto
| LinkAdded of link: ReferenceLinkType
| LinkRemoved of link: ReferenceLinkType
| LogicalDeleted of force: bool * DeleteReason: DeleteReason
| PhysicalDeleted
| Undeleted
Expand Down
12 changes: 6 additions & 6 deletions src/Grace.Actors/Grace.Actors.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.21.0-beta.1" />
<PackageReference Include="Azure.Storage.Blobs.Batch" Version="12.18.0-beta.1" />
<PackageReference Include="Azure.Storage.Common" Version="12.20.0-beta.1" />
<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="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.41.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0-preview.5.24306.7" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.42.0-preview.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" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.2.0" />
Expand All @@ -65,7 +65,7 @@
</ItemGroup>-->

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="8.0.300" />
<PackageReference Update="FSharp.Core" Version="8.0.301" />
</ItemGroup>

</Project>
10 changes: 8 additions & 2 deletions src/Grace.Actors/Reference.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ module Reference =
let referenceEvents = List<ReferenceEvent>()

/// Indicates that the actor is in an undefined state, and should be reset.
let mutable isDisposed = false
let mutable isDisposed = false
let updateDto referenceEventType currentReferenceDto =
let newReferenceDto =
match referenceEventType with
Expand All @@ -53,7 +53,11 @@ module Reference =
DirectoryId = createdDto.DirectoryId
Sha256Hash = createdDto.Sha256Hash
ReferenceType = createdDto.ReferenceType
ReferenceText = createdDto.ReferenceText }
ReferenceText = createdDto.ReferenceText
Links = createdDto.Links
}
| 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}
Expand Down Expand Up @@ -385,6 +389,8 @@ module Reference =
task {
match command with
| Create dto -> return Created dto
| AddLink link -> return LinkAdded link
| RemoveLink link -> return LinkRemoved link
| DeleteLogical(force, deleteReason) ->
let repositoryActorProxy = actorProxyFactory.CreateActorProxy<IRepositoryActor>(ActorId($"{referenceDto.RepositoryId}"), ActorName.Repository)
let! repositoryDto = repositoryActorProxy.Get(metadata.CorrelationId)
Expand Down
33 changes: 16 additions & 17 deletions src/Grace.Actors/Repository.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -230,43 +230,41 @@ module Repository =
| Created(name, repositoryId, ownerId, organizationId) ->
// Create the default branch.
let branchId = (Guid.NewGuid())
let branchActorId = Branch.GetActorId(branchId)

let branchActor = Services.actorProxyFactory.CreateActorProxy<IBranchActor>(branchActorId, ActorName.Branch)
let branchActor = Services.actorProxyFactory.CreateActorProxy<IBranchActor>(ActorId($"{branchId}"), ActorName.Branch)

// Only allow promotions and tags on the initial branch.
let initialBranchPermissions = [| ReferenceType.Promotion; ReferenceType.Tag |]
let initialBranchPermissions = [| ReferenceType.Promotion; ReferenceType.Tag; ReferenceType.External |]

let createCommand =
let createInitialBranchCommand =
Commands.Branch.BranchCommand.Create(
branchId,
(BranchName Constants.InitialBranchName),
Constants.DefaultParentBranchId,
InitialBranchName,
DefaultParentBranchId,
ReferenceId.Empty,
repositoryId,
initialBranchPermissions
)

match! branchActor.Handle createCommand repositoryEvent.Metadata with
match! branchActor.Handle createInitialBranchCommand repositoryEvent.Metadata with
| Ok branchGraceReturn ->
logToConsole $"In Repository.Actor.handleEvent: Successfully created the new branch."
// Create an empty directory version, and use that for the initial promotion
let emptyDirectoryId = DirectoryVersionId.NewGuid()

let emptySha256Hash =
computeSha256ForDirectory Constants.RootDirectoryPath (List<LocalDirectoryVersion>()) (List<LocalFileVersion>())
computeSha256ForDirectory RootDirectoryPath (List<LocalDirectoryVersion>()) (List<LocalFileVersion>())

let directoryVersionActorProxy =
Services.actorProxyFactory.CreateActorProxy<IDirectoryVersionActor>(
DirectoryVersion.GetActorId(emptyDirectoryId),
ActorId($"{emptyDirectoryId}"),
ActorName.DirectoryVersion
)

let emptyDirectoryVersion =
DirectoryVersion.Create
emptyDirectoryId
repositoryDto.RepositoryId
Constants.RootDirectoryPath
RootDirectoryPath
emptySha256Hash
(List<DirectoryVersionId>())
(List<FileVersion>())
Expand Down Expand Up @@ -298,14 +296,15 @@ module Repository =
// Set current, empty directory as the based-on reference.
let referenceId = Guid.Parse(promotionGraceReturnValue.Properties[nameof (ReferenceId)])

logToConsole $"In Repository.Actor.handleEvent: Before trying to rebase the initial branch."
let! rebaseResult = branchActor.Handle (Commands.Branch.BranchCommand.Rebase(referenceId)) repositoryEvent.Metadata
logToConsole $"In Repository.Actor.handleEvent: After trying to rebase the initial branch."
//logToConsole $"In Repository.Actor.handleEvent: Before trying to rebase the initial branch."
//let! rebaseResult = branchActor.Handle (Commands.Branch.BranchCommand.Rebase(referenceId)) repositoryEvent.Metadata
//logToConsole $"In Repository.Actor.handleEvent: After trying to rebase the initial branch."


match rebaseResult with
| Ok rebaseGraceReturn -> return Ok(branchId, referenceId)
| Error graceError -> return processGraceError FailedRebasingInitialBranch repositoryEvent graceError
//match rebaseResult with
//| Ok rebaseGraceReturn -> return Ok(branchId, referenceId)
//| Error graceError -> return processGraceError FailedRebasingInitialBranch repositoryEvent graceError
return Ok(branchId, referenceId)
| (_, Error graceError) -> return processGraceError FailedCreatingInitialPromotion repositoryEvent graceError
| (Error graceError, _) -> return processGraceError FailedCreatingEmptyDirectoryVersion repositoryEvent graceError
| Error graceError ->
Expand Down
Loading

0 comments on commit 5962f7d

Please sign in to comment.