예제 #1
0
        public Task Init(string name, IProviderRuntime providerUtilitiesManager, IProviderConfiguration config)
        {
            if (!stateManager.PresetState(ProviderState.Initialized))
            {
                return(TaskDone.Done);
            }
            this.Name                = name;
            providerRuntime          = (IStreamProviderRuntime)providerUtilitiesManager;
            this.runtimeClient       = this.providerRuntime.ServiceProvider.GetRequiredService <IRuntimeClient>();
            fireAndForgetDelivery    = config.GetBoolProperty(FIRE_AND_FORGET_DELIVERY, DEFAULT_VALUE_FIRE_AND_FORGET_DELIVERY);
            optimizeForImmutableData = config.GetBoolProperty(OPTIMIZE_FOR_IMMUTABLE_DATA, DEFAULT_VALUE_OPTIMIZE_FOR_IMMUTABLE_DATA);

            string pubSubTypeString;

            pubSubType = !config.Properties.TryGetValue(STREAM_PUBSUB_TYPE, out pubSubTypeString)
                ? DEFAULT_STREAM_PUBSUB_TYPE
                : (StreamPubSubType)Enum.Parse(typeof(StreamPubSubType), pubSubTypeString);
            if (pubSubType == StreamPubSubType.ExplicitGrainBasedAndImplicit ||
                pubSubType == StreamPubSubType.ExplicitGrainBasedOnly)
            {
                this.streamSubscriptionManager = this.providerRuntime.ServiceProvider
                                                 .GetService <IStreamSubscriptionManagerAdmin>().GetStreamSubscriptionManager(StreamSubscriptionManagerType.ExplicitSubscribeOnly);
            }

            logger = providerRuntime.GetLogger(this.GetType().Name);
            logger.Info("Initialized SimpleMessageStreamProvider with name {0} and with property FireAndForgetDelivery: {1}, OptimizeForImmutableData: {2} " +
                        "and PubSubType: {3}", Name, fireAndForgetDelivery, optimizeForImmutableData, pubSubType);
            stateManager.CommitState();
            return(TaskDone.Done);
        }
예제 #2
0
 /// <summary>
 /// Customises the given serializer settings using provider configuration.
 /// Can be used by any provider, allowing the users to use a standard set of configuration attributes.
 /// </summary>
 /// <param name="settings">The settings to update.</param>
 /// <param name="config">The provider config.</param>
 /// <returns>The updated <see cref="JsonSerializerSettings" />.</returns>
 public static JsonSerializerSettings UpdateSerializerSettings(JsonSerializerSettings settings, IProviderConfiguration config)
 {
     bool useFullAssemblyNames = config.GetBoolProperty(UseFullAssemblyNamesProperty, false);
     bool indentJson = config.GetBoolProperty(IndentJsonProperty, false);
     TypeNameHandling typeNameHandling = config.GetEnumProperty(TypeNameHandlingProperty, settings.TypeNameHandling);
     return UpdateSerializerSettings(settings, useFullAssemblyNames, indentJson, typeNameHandling);
 }
예제 #3
0
        public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.Log  = providerRuntime.GetLogger(nameof(ArangoStorageProvider));
            this.Name = name;

            var databaseName = config.GetProperty("DatabaseName", "Orleans");
            var url          = config.GetProperty("Url", "http://localhost:8529");
            var username     = config.GetProperty("Username", "root");
            var password     = config.GetProperty("Password", "");
            var waitForSync  = config.GetBoolProperty("WaitForSync", true);

            collectionName = config.GetProperty("CollectionName", null);

            var serializationManager = providerRuntime.ServiceProvider.GetRequiredService <SerializationManager>();
            var grainRefConverter    = new GrainReferenceConverter(serializationManager, providerRuntime.GrainFactory);

            ArangoDatabase.ChangeSetting(s =>
            {
                s.Database              = databaseName;
                s.Url                   = url;
                s.Credential            = new NetworkCredential(username, password);
                s.DisableChangeTracking = true;
                s.WaitForSync           = waitForSync;
                s.Serialization.Converters.Add(grainRefConverter);
            });

            jsonSerializerSettings = new JsonSerializer();
            jsonSerializerSettings.Converters.Add(grainRefConverter);

            this.Database = new ArangoDatabase();

            return(Task.CompletedTask);
        }
 public RabbitMQStreamProviderConfig(IProviderConfiguration config)
 {
     NumQueues       = GetOptionalIntProperty(config, "NumQueues", 8);
     HostName        = config.Properties["HostName"];
     Port            = config.GetIntProperty("Port", 5671);
     VirtualHost     = config.Properties["VirtualHost"];
     Exchange        = config.Properties["Exchange"];
     ExchangeType    = config.GetProperty("ExchangeType", "Direct").ToLowerInvariant();
     ExchangeDurable = config.GetBoolProperty("ExchangeDurable", false);
     AutoDelete      = config.GetBoolProperty("AutoDelete", false);
     Queue           = config.Properties["Queue"];
     QueueDurable    = config.GetBoolProperty("QueueDurable", false);
     Namespace       = config.Properties["Namespace"];
     RoutingKey      = config.Properties["RoutingKey"];
     Username        = config.Properties["Username"];
     Password        = config.Properties["Password"];
 }
        public Task Init(string name, IProviderRuntime providerUtilitiesManager, IProviderConfiguration config)
        {
            this.Name       = name;
            providerRuntime = (IStreamProviderRuntime)providerUtilitiesManager;

            fireAndForgetDelivery    = config.GetBoolProperty(FIRE_AND_FORGET_DELIVERY, DEFAULT_VALUE_FIRE_AND_FORGET_DELIVERY);
            optimizeForImmutableData = config.GetBoolProperty(OPTIMIZE_FOR_IMMUTABLE_DATA, DEFAULT_VALUE_OPTIMIZE_FOR_IMMUTABLE_DATA);

            string pubSubTypeString;

            pubSubType = !config.Properties.TryGetValue(STREAM_PUBSUB_TYPE, out pubSubTypeString)
                ? DEFAULT_STREAM_PUBSUB_TYPE
                : (StreamPubSubType)Enum.Parse(typeof(StreamPubSubType), pubSubTypeString);

            logger = providerRuntime.GetLogger(this.GetType().Name);
            logger.Info("Initialized SimpleMessageStreamProvider with name {0} and with property FireAndForgetDelivery: {1}, OptimizeForImmutableData: {2} " +
                        "and PubSubType: {3}", Name, fireAndForgetDelivery, optimizeForImmutableData, pubSubType);
            return(TaskDone.Done);
        }
예제 #6
0
        public RabbitMQStreamProviderConfiguration(IProviderConfiguration config)
        {
            string deployementId;

            if (!config.Properties.TryGetValue("DeploymentId", out deployementId))
            {
                throw new ArgumentException("DeploymentId property not set");
            }
            DeployementId         = deployementId;
            NumQueues             = config.GetIntProperty("NumQueues", 8);
            Exchange              = config.Properties["Exchange"];
            ExchangeType          = config.GetProperty("ExchangeType", "Direct").ToLowerInvariant();
            ExchangeDurable       = config.GetBoolProperty("ExchangeDurable", false);
            AutoDelete            = config.GetBoolProperty("AutoDelete", false);
            Queue                 = config.Properties["Queue"];
            QueueDurable          = config.GetBoolProperty("QueueDurable", false);
            RoutingKey            = config.Properties["RoutingKey"];
            QueueOperationTimeout = config.GetTimeSpanProperty("QueueOperationTimeout", TimeSpan.FromSeconds(15));
            DataConnectionString  = config.GetProperty("DataConnectionString", null);
        }
예제 #7
0
        /// <summary>
        /// Initializes the storage provider.
        /// </summary>
        /// <param name="name">The name of this provider instance.</param>
        /// <param name="providerRuntime">A Orleans runtime object managing all storage providers.</param>
        /// <param name="config">Configuration info for this provider instance.</param>
        /// <returns>Completion promise for this operation.</returns>
        public virtual Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            Log = providerRuntime.GetLogger(GetType().FullName);
            var serializationManager = (SerializationManager)providerRuntime.ServiceProvider.GetService(typeof(SerializationManager));

            serializerSettings                      = OrleansJsonSerializer.GetDefaultSerializerSettings(serializationManager, providerRuntime.GrainFactory);
            serializerSettings.Formatting           = config.GetBoolProperty(OrleansJsonSerializer.IndentJsonProperty, false) ? Formatting.Indented : Formatting.None;
            serializerSettings.TypeNameHandling     = TypeNameHandling.None;
            serializerSettings.DefaultValueHandling = DefaultValueHandling.Include;
            serializerSettings.NullValueHandling    = NullValueHandling.Include;
            return(Task.CompletedTask);
        }
예제 #8
0
 /// <summary>
 /// Utility function to populate config from provider config
 /// </summary>
 /// <param name="providerConfiguration"></param>
 public virtual void PopulateFromProviderConfig(IProviderConfiguration providerConfiguration)
 {
     ConnectionString = providerConfiguration.GetProperty(ConnectionStringName, null);
     if (string.IsNullOrWhiteSpace(ConnectionString))
     {
         throw new ArgumentOutOfRangeException("providerConfiguration", ConnectionStringName + " not set.");
     }
     ConsumerGroup = providerConfiguration.GetProperty(ConsumerGroupName, null);
     if (string.IsNullOrWhiteSpace(ConsumerGroup))
     {
         throw new ArgumentOutOfRangeException("providerConfiguration", ConsumerGroupName + " not set.");
     }
     Path = providerConfiguration.GetProperty(PathName, null);
     if (string.IsNullOrWhiteSpace(Path))
     {
         throw new ArgumentOutOfRangeException("providerConfiguration", PathName + " not set.");
     }
     PrefetchCount = providerConfiguration.GetIntProperty(PrefetchCountName, InvalidPrefetchCount);
     if (PrefetchCount == InvalidPrefetchCount)
     {
         PrefetchCount = null;
     }
     StartFromNow = providerConfiguration.GetBoolProperty(StartFromNowName, StartFromNowDefault);
 }
        public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.Log  = providerRuntime.GetLogger(nameof(ArangoStorageProvider));
            this.Name = name;

            var databaseName = config.GetProperty("DatabaseName", "Orleans");
            var url          = config.GetProperty("Url", "http://localhost:8529");
            var username     = config.GetProperty("Username", "root");
            var password     = config.GetProperty("Password", "password");

            waitForSync = config.GetBoolProperty("WaitForSync", true);

            var grainRefConverter = new GrainReferenceConverter();

            settings = new JsonSerializer();
            settings.DefaultValueHandling  = DefaultValueHandling.Include;
            settings.MissingMemberHandling = MissingMemberHandling.Ignore;
            settings.ConstructorHandling   = ConstructorHandling.AllowNonPublicDefaultConstructor;
            settings.Converters.Add(grainRefConverter);

            if (!isInitialized)
            {
                ArangoDatabase.ChangeSetting(s =>
                {
                    s.Database              = databaseName;
                    s.Url                   = url;
                    s.Credential            = new NetworkCredential(username, password);
                    s.DisableChangeTracking = true;
                    s.WaitForSync           = waitForSync;
                    s.Serialization.Converters.Add(grainRefConverter);
                });
                isInitialized = true;
            }
            Database        = new ArangoDatabase();
            collectionsList = await Database.ListCollectionsAsync();
        }
예제 #10
0
 /// <summary>
 /// Utility function to populate config from provider config
 /// </summary>
 /// <param name="providerConfiguration"></param>
 public virtual void PopulateFromProviderConfig(IProviderConfiguration providerConfiguration)
 {
     ConnectionString = providerConfiguration.GetProperty(ConnectionStringName, null);
     if (string.IsNullOrWhiteSpace(ConnectionString))
     {
         throw new ArgumentOutOfRangeException(nameof(providerConfiguration), ConnectionStringName + " not set.");
     }
     ConsumerGroup = providerConfiguration.GetProperty(ConsumerGroupName, null);
     if (string.IsNullOrWhiteSpace(ConsumerGroup))
     {
         throw new ArgumentOutOfRangeException(nameof(providerConfiguration), ConsumerGroupName + " not set.");
     }
     Path = providerConfiguration.GetProperty(PathName, null);
     if (string.IsNullOrWhiteSpace(Path))
     {
         throw new ArgumentOutOfRangeException(nameof(providerConfiguration), PathName + " not set.");
     }
     PrefetchCount = providerConfiguration.GetIntProperty(PrefetchCountName, InvalidPrefetchCount);
     if (PrefetchCount == InvalidPrefetchCount)
     {
         PrefetchCount = null;
     }
     StartFromNow = providerConfiguration.GetBoolProperty(StartFromNowName, StartFromNowDefault);
 }