/// <summary> /// Initializes a new instance of the <see cref="ChildOperator{TParent, TChild}"/> class. /// </summary> /// <param name="kubernetes"> /// A connection to a Kubernetes cluster. /// </param> /// <param name="configuration"> /// The configuration for this operator. /// </param> /// <param name="parentFilter"> /// A delegate which can be used to only take a subset of the parents in consideration. /// </param> /// <param name="childFactory"> /// A method which projects objects of type <typeparamref name="TParent"/> into objects of type /// <typeparamref name="TChild"/>. /// </param> /// <param name="feedbackLoops"> /// A list of feedback loops which can update the state of the parent object depending /// on the state of the child object. /// </param> /// <param name="logger"> /// The logger to use when logging. /// </param> /// <param name="services"> /// A <see cref="IServiceProvider"/> which is passed to the feedback loops. /// </param> public ChildOperator( KubernetesClient kubernetes, ChildOperatorConfiguration configuration, Func <TParent, bool> parentFilter, Action <TParent, TChild> childFactory, Collection <FeedbackLoop <TParent, TChild> > feedbackLoops, ILogger <ChildOperator <TParent, TChild> > logger, IServiceProvider services) { this.kubernetes = kubernetes ?? throw new ArgumentNullException(nameof(kubernetes)); this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); this.parentFilter = parentFilter ?? throw new ArgumentNullException(nameof(parentFilter)); this.childFactory = childFactory ?? throw new ArgumentNullException(nameof(childFactory)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.feedbackLoops = feedbackLoops ?? throw new ArgumentNullException(nameof(feedbackLoops)); this.services = services ?? throw new ArgumentNullException(nameof(services)); this.parentClient = this.kubernetes.GetClient <TParent>(); this.childClient = this.kubernetes.GetClient <TChild>(); }
/// <summary> /// Configures the builder to create a new operator. /// </summary> /// <param name="operatorName"> /// The name of the operator to create. /// </param> /// <returns> /// A builder which can be used to futher configure the operator. /// </returns> public ChildOperatorBuilder CreateOperator(string operatorName) { this.configuration = new ChildOperatorConfiguration(operatorName); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="ChildOperatorBuilder{TParent}"/> class. /// </summary> /// <param name="services"> /// The service collection from which to source required services. /// </param> /// <param name="configuration"> /// The configuration to apply to the operator. /// </param> public ChildOperatorBuilder(IServiceProvider services, ChildOperatorConfiguration configuration) { this.services = services ?? throw new ArgumentNullException(nameof(services)); this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); }