Ejemplo n.º 1
0
        /// <summary>
        /// Adds and runs provided applications one by one.
        /// May throw an exception if application with one of the identifiers has already been added.
        /// <see cref="VostokMultiHost"/> should be running to perform this operation.
        /// </summary>
        public static async Task RunSequentiallyAsync(this VostokMultiHost host, IEnumerable <VostokMultiHostApplicationSettings> apps)
        {
            var addedApps = apps.Select(host.AddApplication).ToArray();

            foreach (var app in addedApps)
            {
                await app.RunAsync().ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Stops provided application if it was added before.
        /// <see cref="VostokMultiHost"/> should be running to perform this operation.
        /// </summary>
        public static Task <VostokApplicationRunResult> StopApplicationAsync(this VostokMultiHost host, VostokMultiHostApplicationIdentifier identifier)
        {
            var application = host.GetApplication(identifier);

            if (application == null)
            {
                throw new InvalidOperationException($"{identifier} doesn't exist.");
            }

            return(application.StopAsync());
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds and starts provided applications in parallel.
 /// May throw an exception if application with one of the identifiers has already been added.
 /// <see cref="VostokMultiHost"/> should be running to perform this operation.
 /// </summary>
 public static Task StartInParallelAsync(this VostokMultiHost host, params VostokMultiHostApplicationSettings[] apps)
 {
     return(StartInParallelAsync(host, (IEnumerable <VostokMultiHostApplicationSettings>)apps));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds and starts provided applications in parallel.
 /// May throw an exception if application with one of the identifiers has already been added.
 /// <see cref="VostokMultiHost"/> should be running to perform this operation.
 /// </summary>
 public static Task StartInParallelAsync(this VostokMultiHost host, IEnumerable <VostokMultiHostApplicationSettings> apps)
 {
     return(Task.WhenAll(apps.Select(app => StartApplicationAsync(host, app))));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds an application and returns <see cref="IVostokMultiHostApplication.StartAsync"/> task.
 /// May throw an exception if application with this identifier has already been added.
 /// <see cref="VostokMultiHost"/> should be running to perform this operation.
 /// </summary>
 public static Task StartApplicationAsync(this VostokMultiHost host, VostokMultiHostApplicationSettings settings)
 {
     return(host.AddApplication(settings).StartAsync());
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds an application and returns <see cref="IVostokMultiHostApplication.RunAsync"/> task.
 /// May throw an exception if application with this identifier has already been added.
 /// <see cref="VostokMultiHost"/> should be running to perform this operation.
 /// </summary>
 public static Task <VostokApplicationRunResult> RunApplicationAsync(this VostokMultiHost host, VostokMultiHostApplicationSettings settings)
 {
     return(host.AddApplication(settings).RunAsync());
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Adds and runs provided applications one by one.
 /// May throw an exception if application with one of the identifiers has already been added.
 /// <see cref="VostokMultiHost"/> should be running to perform this operation.
 /// </summary>
 public static Task RunSequentiallyAsync(this VostokMultiHost host, params VostokMultiHostApplicationSettings[] apps)
 {
     return(RunSequentiallyAsync(host, (IEnumerable <VostokMultiHostApplicationSettings>)apps));
 }