Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'petabridge/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed Apr 28, 2022
2 parents 1d024ed + 377c7c3 commit d32bbfb
Show file tree
Hide file tree
Showing 20 changed files with 365 additions and 24 deletions.
11 changes: 11 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="akka-nightly" value="https://f.feedz.io/akkadotnet/akka/nuget/index.json" />
</packageSources>
</configuration>
65 changes: 65 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,68 @@
## [0.5.12] / 25 April 2022
- Added `DistributedPubSub` - but made it optional
- Disabled `DistributedPubSub`
- Set `state-store-mode=persistence`
- Hard code disable DData
- Actually use `ShardOptions`
- Run with Akka.NET v1.5.0-beta

## [0.5.11] / 25 April 2022
- Added `DistributedPubSub` - but made it optional
- Disabled `DistributedPubSub`
- Set `state-store-mode=persistence`
- Hard code disable DData
- Run with Akka.NET v1.5.0-beta


## [0.5.10] / 25 April 2022
- Added `DistributedPubSub` - but made it optional
- Disabled `DistributedPubSub`
- Set `state-store-mode=persistence`
- Run with Akka.NET v1.5.0-beta


## [0.5.9] / 21 April 2022
- Added `DistributedPubSub`
- Run with Akka.NET v1.5.0-beta

## [0.5.5] / 21 April 2022
- Disable `remember-entities`, but keep DData
- Disable K8s lease
- Run with Akka.NET v1.5.0-beta

## [0.5.4] / 20 April 2022
- Disable `remember-entities`, but keep DData
- Enable K8s lease
- Run with Akka.NET v1.5.0-beta

## [0.5.3] / 20 April 2022
- Enable `remember-entities` with `state-store-mode=ddata`
- Log the version of Akka.Cluster.Sharding being used
- Run with Akka.NET v1.5.0-beta

## [0.5.2] / 20 April 2022
- Enable `remember-entities` with `state-store-mode=ddata`
- Log the version of Akka.Cluster.Sharding being used
- Run with Akka.NET v1.4.37

## [0.5.1] / 20 April 2022
- Enable `remember-entities`
- Log the version of Akka.Cluster.Sharding being used
- Run with Akka.NET v1.5.0-beta

## [0.4.9] / 20 April 2022
- Enable `remember-entities`
- Log the version of Akka.Cluster.Sharding being used
- Run with Akka.NET v1.4.37

## [0.4.8] / 20 April 2022
- Enable `remember-entities`
- Log the version of Akka.Cluster.Sharding being used
- Run with Akka.NET v1.4.37

## [0.4.7] / 20 April 2022
- Test with Akka.NET v1.5 with https://github.com/akkadotnet/akka.net/pull/4629 merged in

## [0.4.6] / 19 April 2022
- Arbitrary bump for deployment purposes

Expand Down
1 change: 1 addition & 0 deletions k8s/local/environment/configs/configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data:
# standard Akka.NET ports for all services
StressOptions__AkkaClusterOptions__ManagementPort: "9221"
StressOptions__AkkaClusterOptions__ManagementPort: "9228"
StressOptions__AkkaClusterOptions__UseKubernetesLease: "true"

# configure Akka.Management K8s service discovery
StressOptions__AkkaClusterOptions__UseKubernetesDiscovery: "true"
Expand Down
54 changes: 54 additions & 0 deletions k8s/local/environment/configs/k8s-lease-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
# name must match the spec fields below, and be in the form: <plural>.<group>
name: leases.akka.io
spec:
group: akka.io
versions:
- name: v1
storage: true
served: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
owner:
type: string
version:
type: string
time:
type: integer
scope: Namespaced
names:
# kind is normally the CamelCased singular type. Your resource manifests use this.
kind: Lease
listKind: LeaseList
# singular name to be used as an alias on the CLI and for display
singular: lease
# plural name to be used in the URL: /apis/<group>/<version>/<plural>
plural: leases
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: lease-access
rules:
- apiGroups: ["akka.io"]
resources: ["leases"]
verbs: ["get", "create", "update", "list"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: lease-access
subjects:
- kind: User
name: system:serviceaccount:akkastress:default
roleRef:
kind: Role
name: lease-access
apiGroup: rbac.authorization.k8s.io
4 changes: 2 additions & 2 deletions k8s/local/services/local-services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ spec:
emptyDir: {}
containers:
- name: frontend
image: akkadotnet.frontend:0.3.4
image: akkadotnet.frontend:0.5.9
env:
- name: POD_NAME
valueFrom:
Expand Down Expand Up @@ -207,7 +207,7 @@ spec:
emptyDir: {}
containers:
- name: backend
image: akkadotnet.backend:0.3.4
image: akkadotnet.backend:0.5.9
env:
- name: POD_NAME
valueFrom:
Expand Down
8 changes: 8 additions & 0 deletions k8s/prod/environment/configs/configs-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ data:
# standard Akka.NET ports for all services
StressOptions__AkkaClusterOptions__ManagementPort: "9221"
StressOptions__AkkaClusterOptions__ManagementPort: "9228"
StressOptions__AkkaClusterOptions__UseKubernetesLease: "false"

# DistributedPubSub options
StressOptions__DistributedPubSubOptions__Enabled: "false"

# Sharding options
StressOptions__ShardingOptions__Enabled: "true"
StressOptions__ShardingOptions__UseDData: "false"

# configure Akka.Management K8s service discovery
StressOptions__AkkaClusterOptions__UseKubernetesDiscovery: "true"
Expand Down
54 changes: 54 additions & 0 deletions k8s/prod/environment/configs/k8s-lease-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
# name must match the spec fields below, and be in the form: <plural>.<group>
name: leases.akka.io
spec:
group: akka.io
versions:
- name: v1
storage: true
served: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
owner:
type: string
version:
type: string
time:
type: integer
scope: Namespaced
names:
# kind is normally the CamelCased singular type. Your resource manifests use this.
kind: Lease
listKind: LeaseList
# singular name to be used as an alias on the CLI and for display
singular: lease
# plural name to be used in the URL: /apis/<group>/<version>/<plural>
plural: leases
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: lease-access
rules:
- apiGroups: ["akka.io"]
resources: ["leases"]
verbs: ["get", "create", "update", "list"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: lease-access
subjects:
- kind: User
name: system:serviceaccount:akkastress:default
roleRef:
kind: Role
name: lease-access
apiGroup: rbac.authorization.k8s.io
6 changes: 3 additions & 3 deletions k8s/prod/services/prod-services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ spec:
emptyDir: {}
containers:
- name: frontend
image: akkalargescaleimages64b06635.azurecr.io/akkadotnet.frontend:0.4.6
image: akkalargescaleimages64b06635.azurecr.io/akkadotnet.frontend:0.5.12
env:
- name: POD_NAME
valueFrom:
Expand Down Expand Up @@ -190,7 +190,7 @@ metadata:
akkacluster: stress
spec:
serviceName: "backend-akka"
replicas: 130
replicas: 197
selector:
matchLabels:
app: backend
Expand All @@ -207,7 +207,7 @@ spec:
emptyDir: {}
containers:
- name: backend
image: akkalargescaleimages64b06635.azurecr.io/akkadotnet.backend:0.4.6
image: akkalargescaleimages64b06635.azurecr.io/akkadotnet.backend:0.5.12
env:
- name: POD_NAME
valueFrom:
Expand Down
9 changes: 7 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
<PropertyGroup>
<Copyright>Copyright © 2022 Petabridge</Copyright>
<Authors>Petabridge</Authors>
<VersionPrefix>0.4.6</VersionPrefix>
<PackageReleaseNotes>• Arbitrary bump for deployment purposes</PackageReleaseNotes>
<VersionPrefix>0.5.12</VersionPrefix>
<PackageReleaseNotes>• Added DistributedPubSub • but made it optional
• Disabled DistributedPubSub
• Set state-store-mode=persistence
• Hard code disable DData
• Actually use ShardOptions
• Run with Akka.NET v1.5.0-beta</PackageReleaseNotes>
<PackageIconUrl>
</PackageIconUrl>
<PackageProjectUrl>
Expand Down
40 changes: 35 additions & 5 deletions src/backend/AkkaDotNet.BackEnd/Actors/ItemActor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Akka.Actor;
using Akka.Cluster.Sharding;
using Akka.Cluster.Tools.PublishSubscribe;
using Akka.Event;
using Akka.Persistence;
using AkkaDotNet.Infrastructure;
using AkkaDotNet.Messages;
using AkkaDotNet.Messages.Commands;
using AkkaDotNet.Messages.Events;
Expand All @@ -10,17 +13,19 @@ namespace AkkaDotNet.BackEnd.Actors;
public class ItemActor : ReceivePersistentActor
{
private int _count = 0;
private readonly bool _pubSubEnabled;
private readonly ILoggingAdapter _log = Context.GetLogger();
public static Props PropsFor(string itemId)

public static Props PropsFor(string itemId, bool pubSubEnabled)
{
return Props.Create(() => new ItemActor(itemId));
return Props.Create(() => new ItemActor(itemId, pubSubEnabled));
}

public ItemActor(string persistenceId)
public ItemActor(string persistenceId, bool pubSubEnabled)
{
PersistenceId = persistenceId;

_pubSubEnabled = pubSubEnabled;

Recover<ItemAdded>(i =>
{
_log.Info("Recovery: count was {0} - adding {1}", _count, i.Count);
Expand Down Expand Up @@ -69,6 +74,21 @@ public ItemActor(string persistenceId)
DeleteMessages(s.Metadata.SequenceNr);
DeleteSnapshots(new SnapshotSelectionCriteria(s.Metadata.SequenceNr-1));
});

Command<ReceiveTimeout>(_ =>
{
Context.Parent.Tell(new Passivate(PoisonPill.Instance));
});

Command<SubscribeAck>(a =>
{
_log.Info("Confirmed subscription to [{0}]", a.Subscribe.Topic);
});

Command<Ping>(p =>
{
Sender.Tell(p);
});
}

private void SaveSnapshotWhenAble()
Expand All @@ -80,4 +100,14 @@ private void SaveSnapshotWhenAble()
}

public override string PersistenceId { get; }

protected override void PreStart()
{
Context.SetReceiveTimeout(TimeSpan.FromMinutes(2));
if (_pubSubEnabled)
{
var mediator = DistributedPubSub.Get(Context.System).Mediator;
mediator.Tell(new Subscribe(ActorSystemConstants.PingTopicName, Self), Self);
}
}
}
20 changes: 12 additions & 8 deletions src/backend/AkkaDotNet.BackEnd/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Akka.Actor;
using Akka.Cluster.Hosting;
using Akka.Cluster.Sharding;
Expand Down Expand Up @@ -25,14 +26,17 @@
new[] { ActorSystemConstants.BackendRole, ActorSystemConstants.DistributedPubSubRole });
configurationBuilder.WithSerilog(akkaConfiguration.SerilogOptions);
configurationBuilder.WithReadyCheckActors();
configurationBuilder.WithShardRegion<IWithItem>("items", s => ItemActor.PropsFor(s), new ItemShardExtractor(),
new ShardOptions()
{
RememberEntities = false,
Role = ActorSystemConstants.BackendRole,
StateStoreMode = StateStoreMode.Persistence
})
.WithItemMessagingActor();
if (akkaConfiguration.ShardingOptions.Enabled)
{
configurationBuilder.WithShardRegion<IWithItem>("items", s => ItemActor.PropsFor(s, akkaConfiguration.DistributedPubSubOptions.Enabled), new ItemShardExtractor(),
new ShardOptions()
{
RememberEntities = akkaConfiguration.ShardingOptions.RememberEntities,
Role = ActorSystemConstants.BackendRole,
StateStoreMode = akkaConfiguration.ShardingOptions.UseDData ? StateStoreMode.DData : StateStoreMode.Persistence
})
.WithItemMessagingActor();
}
});

builder.Services.AddOpenTelemetry();
Expand Down
Loading

0 comments on commit d32bbfb

Please sign in to comment.