Пример #1
0
        /// <summary>
        /// Runs the cluster client startup task.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        protected override async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            await ClusterClient.Connect(async ex =>
            {
                cancellationToken.ThrowIfCancellationRequested();

                await Task.Delay(TimeSpan.FromMilliseconds(300), cancellationToken).ConfigureAwait(false);
                return(true);
            }).ConfigureAwait(false);

            StartupContext.MarkTaskAsComplete();
        }
Пример #2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Connecting...");

            var maxRetries = _configuration.GetValue <int>("Orleans:Client:Connect:MaxRetries");
            var retryDelay = _configuration.GetValue <TimeSpan>("Orleans:Client:Connect:RetryDelay");
            await ClusterClient.Connect(async error =>
            {
                _logger.LogError(error, "Error Connecting: {@Message}", error.Message);
                if (--maxRetries < 0)
                {
                    return(false);
                }
                await Task.Delay(retryDelay, cancellationToken);
                return(true);
            });

            _logger.LogInformation("Connected.");
        }
Пример #3
0
 public static async Task StartAsync()
 {
     if (ClusterClient == null)
     {
         ClusterClient = new ClientBuilder()
                         .UseLocalhostClustering()
                         .Configure <ClusterOptions>(options =>
         {
             options.ClusterId = "GameState";
             options.ServiceId = "ServerEngine";
         })
                         .ConfigureApplicationParts(parts =>
         {
             parts.AddApplicationPart(typeof(IGameUniverseGrain).Assembly).WithReferences();
         })
                         .ConfigureLogging(logging =>
         {
             logging.AddConsole();
         })
                         .Build();
     }
     await ClusterClient.Connect();
 }
Пример #4
0
        /// <summary>
        /// Creates a Cluster Server that creates Fragment Servers to be used.
        /// TODO: Will currently only create a single server for itself.
        /// </summary>
        public ClusterServer(int _maxConnections = 0, ushort _port = 6257) : base(ServerType.ClusterServer, _maxConnections, _port)
        {
            Start(ServerType.ClusterServer);

            masterConn.Connect();
        }