示例#1
0
        /// <summary>
        ///     Update server ingress details.
        /// </summary>
        /// <param name="serverIngressChanged">
        ///     A <see cref="ServerIngressChanged"/> message describing the change.
        /// </param>
        /// <returns>
        ///     A <see cref="Task"/> representing the operation.
        /// </returns>
        async Task UpdateServerIngress(ServerIngressChanged serverIngressChanged)
        {
            if (serverIngressChanged == null)
            {
                throw new ArgumentNullException(nameof(serverIngressChanged));
            }

            using (IAsyncDocumentSession session = DocumentStore.OpenAsyncSession())
            {
                DatabaseServer server = await session.LoadAsync <DatabaseServer>(serverIngressChanged.ServerId);

                if (server == null)
                {
                    Log.Warning("Received ServerIngressChanged notification for non-existent server (Id:{ServerId}).",
                                serverIngressChanged.ServerId
                                );

                    return;
                }

                server.PublicFQDN = serverIngressChanged.PublicFQDN;
                server.PublicPort = serverIngressChanged.PublicPort;
                server.AddIngressChangedEvent();

                await session.SaveChangesAsync();
            }
        }