protected void Initialize(IServiceProvider provider) { StreamProviderManager = provider.GetRequiredService <IStreamProviderManager>(); GrainFactory = provider.GetRequiredService <IGrainFactory>(); ActorInterface.Bind(GrainFactory); }
public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config) { var factory = providerRuntime.GrainFactory; ActorInterface.Bind(factory); return(TaskDone.Done); }
/// <summary> /// Connects this instance of client actor system to cluster /// </summary> /// <param name="retries">Number of retries in case on failure</param> /// <param name="retryTimeout">Timeout between retries. Default is 5 seconds</param> /// <exception cref="ArgumentOutOfRangeException">if <paramref name="retries"/> argument value is less than 0</exception> public void Connect(int retries = 0, TimeSpan?retryTimeout = null) { if (retryTimeout == null) { retryTimeout = TimeSpan.FromSeconds(5); } if (retries < 0) { throw new ArgumentOutOfRangeException(nameof(retries), "retries should be greater than or equal to 0"); } while (!Connected && retries-- >= 0) { try { GrainClient.Initialize(configuration); } catch (Exception ex) { if (retries >= 0) { Trace.TraceWarning($"Can't connect to cluster. Trying again in {(int)retryTimeout.Value.TotalSeconds} seconds ... Got error: /n{ex}"); Thread.Sleep(retryTimeout.Value); } else { Trace.TraceError($"Can't connect to cluster. Max retries reached. Got error: /n{ex}"); throw; } } } ActorInterface.Bind(GrainClient.GrainFactory); }