示例#1
0
        private Task <WatchExitReason> WatchObjectAsync <TObject, TList>(
            TObject value,
            ListObjectWithHttpMessagesAsync <TObject, TList> listOperation,
            WatchEventDelegate <TObject> eventHandler,
            CancellationToken cancellationToken)
            where TObject : IKubernetesObject <V1ObjectMeta>
            where TList : IItems <TObject>
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (value.Metadata == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "value.Metadata");
            }

            if (value.Metadata.Name == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "value.Metadata.Name");
            }

            return(this.WatchObjectAsync <TObject, TList>(
                       fieldSelector: $"metadata.name={value.Metadata.Name}",
                       value.Metadata.ResourceVersion,
                       listOperation,
                       eventHandler,
                       cancellationToken));
        }
示例#2
0
        private async Task <WatchExitReason> WatchObjectAsync <TObject, TList>(
            string fieldSelector,
            string resourceVersion,
            ListObjectWithHttpMessagesAsync <TObject, TList> listOperation,
            WatchEventDelegate <TObject> eventHandler,
            CancellationToken cancellationToken)
            where TObject : IKubernetesObject <V1ObjectMeta>
            where TList : IItems <TObject>
        {
            if (eventHandler == null)
            {
                throw new ArgumentNullException(nameof(eventHandler));
            }

            using (var response = await listOperation(
                       fieldSelector: fieldSelector,
                       resourceVersion: resourceVersion,
                       watch: true,
                       cancellationToken: cancellationToken).ConfigureAwait(false))
            {
                return(await this.WatchAsync(response, eventHandler, cancellationToken).ConfigureAwait(false));
            }
        }