Skip to content

Commit

Permalink
Move all event sourcing code into Orleans.EventSourcing
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond committed Feb 10, 2021
1 parent d59798a commit 8a8828c
Show file tree
Hide file tree
Showing 41 changed files with 44 additions and 183 deletions.
2 changes: 0 additions & 2 deletions src/Orleans.Core/Providers/IOrleansProvider.cs
Expand Up @@ -12,8 +12,6 @@ namespace Orleans.Providers
/// Base interface for all type-specific provider interfaces in Orleans
/// </summary>
/// <seealso cref="Orleans.Storage.IStorageProvider"/>
/// <seealso cref="Orleans.LogConsistency.ILogConsistencyProvider"/>

public interface IProvider
{
/// <summary>The name of this provider instance, as given to it in the config.</summary>
Expand Down
4 changes: 0 additions & 4 deletions src/Orleans.Core/SystemTargetInterfaces/IManagementGrain.cs
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Orleans.Runtime.Configuration;
using Orleans.MultiCluster;
using Orleans.Versions.Compatibility;
using Orleans.Versions.Selector;

namespace Orleans.Runtime
{
Expand Down
2 changes: 0 additions & 2 deletions src/Orleans.EventSourcing/Common/ConnectionIssues.cs
@@ -1,10 +1,8 @@
using System;
using Orleans.Internal;
using Orleans.LogConsistency;

namespace Orleans.EventSourcing.Common
{

/// <summary>
/// Describes a connection issue that occurred when sending update notifications to remote instances.
/// </summary>
Expand Down
6 changes: 1 addition & 5 deletions src/Orleans.EventSourcing/Common/NotificationMessage.cs
@@ -1,9 +1,6 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Orleans.MultiCluster;

namespace Orleans.EventSourcing.Common
{
Expand Down Expand Up @@ -44,5 +41,4 @@ public class BatchedNotificationMessage : INotificationMessage
}
}
}

}
@@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Orleans.LogConsistency;
using System.Diagnostics;
using Microsoft.Extensions.Logging;
using Orleans.Serialization;
using Orleans.MultiCluster;
using Orleans.Runtime;
using Orleans.GrainDirectory;

namespace Orleans.EventSourcing.Common
{
Expand Down
4 changes: 0 additions & 4 deletions src/Orleans.EventSourcing/Common/RecordedConnectionIssue.cs
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Orleans.LogConsistency;

namespace Orleans.EventSourcing.Common
{
Expand Down
8 changes: 1 addition & 7 deletions src/Orleans.EventSourcing/Common/StringEncodedWriteVector.cs
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Orleans.EventSourcing.Common
namespace Orleans.EventSourcing.Common
{
public static class StringEncodedWriteVector
{
Expand Down
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Orleans.EventSourcing.CustomStorage
Expand Down
@@ -1,5 +1,3 @@

using Orleans.LogConsistency;
using Orleans.Storage;
using Orleans.Configuration;
using System;
Expand Down
5 changes: 0 additions & 5 deletions src/Orleans.EventSourcing/CustomStorage/LogViewAdaptor.cs
Expand Up @@ -2,14 +2,9 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Orleans;
using Orleans.LogConsistency;
using Orleans.Runtime;
using Orleans.Storage;
using Orleans.MultiCluster;
using Orleans.EventSourcing.Common;

namespace Orleans.EventSourcing.CustomStorage
Expand Down
@@ -1,7 +1,7 @@


using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Orleans.LogConsistency;
using Orleans.EventSourcing;
using Orleans.Providers;
using Orleans.Runtime;
using Orleans.EventSourcing.CustomStorage;
Expand Down
@@ -1,10 +1,11 @@

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Orleans.LogConsistency;
using Orleans.EventSourcing;
using Orleans.Providers;
using Orleans.Runtime;
using Orleans.EventSourcing.LogStorage;
using Orleans.Runtime.LogConsistency;

namespace Orleans.Hosting
{
Expand Down Expand Up @@ -44,6 +45,11 @@ public static ISiloBuilder AddLogStorageBasedLogConsistencyProvider(this ISiloBu

internal static IServiceCollection AddLogStorageBasedLogConsistencyProvider(this IServiceCollection services, string name)
{
services.TryAddSingleton<Factory<Grain, ILogConsistencyProtocolServices>>(serviceProvider =>
{
var factory = ActivatorUtilities.CreateFactory(typeof(ProtocolServices), new[] { typeof(Grain) });
return arg1 => (ILogConsistencyProtocolServices)factory(serviceProvider, new object[] { arg1 });
});
services.TryAddSingleton<ILogViewAdaptorFactory>(sp => sp.GetServiceByName<ILogViewAdaptorFactory>(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME));
return services.AddSingletonNamedService<ILogViewAdaptorFactory, LogConsistencyProvider>(name);
}
Expand Down
@@ -1,7 +1,7 @@


using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Orleans.LogConsistency;
using Orleans.EventSourcing;
using Orleans.Providers;
using Orleans.Runtime;
using Orleans.EventSourcing.StateStorage;
Expand Down
5 changes: 0 additions & 5 deletions src/Orleans.EventSourcing/JournaledGrain.cs
@@ -1,11 +1,6 @@
using Orleans.Concurrency;
using Orleans.MultiCluster;
using Orleans.LogConsistency;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Orleans.Core;
using Orleans.Runtime;
using Orleans.Storage;

namespace Orleans.EventSourcing
Expand Down
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;

namespace Orleans.LogConsistency
namespace Orleans.EventSourcing
{

/// <summary>
/// Represents information about connection issues encountered inside log consistency protocols.
/// It is used both inside the protocol to track retry loops, and is made visible to users
Expand Down
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Orleans.LogConsistency
namespace Orleans.EventSourcing
{
/// <summary>
/// An interface that is implemented by log-consistent grains using virtual protected methods
Expand Down
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Orleans.LogConsistency
namespace Orleans.EventSourcing
{
/// <summary>
/// Interface for diagnostics.
Expand Down
@@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Orleans.MultiCluster;
using Orleans.EventSourcing;
using Orleans.Runtime;
using Orleans.Concurrency;


namespace Orleans.SystemTargetInterfaces
{
Expand All @@ -18,5 +12,4 @@ internal interface ILogConsistencyProtocolGateway : ISystemTarget
{
Task<ILogConsistencyProtocolMessage> RelayMessage(GrainId id, ILogConsistencyProtocolMessage payload);
}

}
@@ -1,16 +1,10 @@
using System;
using System.Net;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
using Orleans.Providers;
using Orleans.Runtime;
using Orleans.MultiCluster;
using Orleans.GrainDirectory;
using Orleans.Serialization;

namespace Orleans.LogConsistency
namespace Orleans.EventSourcing
{
/// <summary>
/// Functionality for use by log view adaptors that use custom consistency or replication protocols.
Expand Down
@@ -1,11 +1,8 @@
using Orleans.MultiCluster;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Orleans.LogConsistency
namespace Orleans.EventSourcing
{
/// <summary>
/// A log view adaptor is the storage interface for <see cref="LogConsistentGrain{T}"/>, whose state is defined as a log view.
Expand Down
@@ -1,7 +1,7 @@

using Orleans.Storage;

namespace Orleans.LogConsistency
namespace Orleans.EventSourcing
{
/// <summary>
/// Interface to be implemented for a log-view adaptor factory
Expand Down
@@ -1,11 +1,4 @@
using Orleans.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Orleans.LogConsistency
namespace Orleans.EventSourcing
{
/// <summary>
/// Interface implemented by all grains which use log-view consistency
Expand Down
@@ -1,7 +1,6 @@
using System.Threading.Tasks;
using Orleans.Concurrency;

namespace Orleans.MultiCluster
namespace Orleans.EventSourcing
{
/// <summary>
/// Grain interface for grains that participate in multi-cluster log-consistency protocols.
Expand Down
Expand Up @@ -4,14 +4,11 @@
using System.Threading.Tasks;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Orleans.Core;
using Orleans.Runtime;
using Orleans.Storage;
using Orleans.GrainDirectory;
using Orleans.Providers;
using Orleans.MultiCluster;

namespace Orleans.LogConsistency
namespace Orleans.EventSourcing
{
/// <summary>
/// Base class for all grains that use log-consistency for managing the state.
Expand Down Expand Up @@ -40,14 +37,22 @@ public abstract class LogConsistentGrain<TView> : Grain, ILifecycleParticipant<I
public override void Participate(IGrainLifecycle lifecycle)
{
base.Participate(lifecycle);
lifecycle.Subscribe<ClientOptionsLogger>(GrainLifecycleStage.SetupState, OnSetupState);
if(this is ILogConsistencyProtocolParticipant)
lifecycle.Subscribe<LogConsistentGrain<TView>>(GrainLifecycleStage.SetupState, OnSetupState, OnDeactivateState);
if (this is ILogConsistencyProtocolParticipant)
{
lifecycle.Subscribe<LogConsistentGrain<TView>>(GrainLifecycleStage.Activate - 1, PreActivate);
lifecycle.Subscribe<LogConsistentGrain<TView>>(GrainLifecycleStage.Activate + 1, PostActivate);
}
}

private async Task OnDeactivateState(CancellationToken ct)
{
if (this is ILogConsistencyProtocolParticipant participant)
{
await participant.DeactivateProtocolParticipant();
}
}

private Task OnSetupState(CancellationToken ct)
{
if (ct.IsCancellationRequested) return Task.CompletedTask;
Expand Down Expand Up @@ -82,7 +87,6 @@ private async Task PostActivate(CancellationToken ct)
this.InstallAdaptor(factory, state, this.GetType().FullName, grainStorage, svc);
}


private ILogViewAdaptorFactory SetupLogConsistencyProvider(IGrainContext activationContext)
{
var attr = this.GetType().GetCustomAttributes<LogConsistencyProviderAttribute>(true).FirstOrDefault();
Expand Down
@@ -1,14 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Orleans.Configuration;
using Orleans.LogConsistency;
using Orleans.MultiCluster;
using Orleans.SystemTargetInterfaces;
using Orleans.GrainDirectory;
using Orleans.EventSourcing;
using Orleans.Serialization;

namespace Orleans.Runtime.LogConsistency
Expand All @@ -23,14 +15,14 @@ internal class ProtocolServices : ILogConsistencyProtocolServices
private static readonly object[] EmptyObjectArray = new object[0];

private readonly ILogger log;
private readonly IInternalGrainFactory grainFactory;
private readonly IGrainFactory grainFactory;
private readonly Grain grain; // links to the grain that owns this service object

public ProtocolServices(
Grain gr,
ILoggerFactory loggerFactory,
SerializationManager serializationManager,
IInternalGrainFactory grainFactory,
IGrainFactory grainFactory,
ILocalSiloDetails siloDetails)
{
this.grain = gr;
Expand Down
8 changes: 0 additions & 8 deletions src/Orleans.EventSourcing/LogStorage/DefaultAdaptorFactory.cs
@@ -1,12 +1,4 @@
using Orleans.LogConsistency;
using Orleans.Providers;
using Orleans.Runtime;
using Orleans.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Orleans.EventSourcing.LogStorage
{
Expand Down
@@ -1,5 +1,3 @@

using Orleans.LogConsistency;
using Orleans.Storage;


Expand Down

0 comments on commit 8a8828c

Please sign in to comment.