001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.rest.server.health;
018
019import java.time.*;
020
021/**
022 * Settings for the built-in health probe resource.
023 *
024 * @since 10.0.0
025 */
026public class HealthProbeSettings {
027
028   private final Duration timeout;
029
030   private HealthProbeSettings(Builder b) {
031      this.timeout = b.timeout;
032   }
033
034   /**
035    * Builder creator.
036    *
037    * @return New builder.
038    */
039   public static Builder create() {
040      return new Builder();
041   }
042
043   /**
044    * @return Per-indicator timeout.
045    */
046   public Duration getTimeout() {
047      return timeout;
048   }
049
050   /**
051    * Builder for {@link HealthProbeSettings}.
052    */
053   public static class Builder {
054      private Duration timeout = Duration.ofSeconds(1);
055
056      /**
057       * Sets per-indicator timeout.
058       *
059       * @param value Timeout value. Can be <jk>null</jk> (defaults to 1 second).
060       * @return This object.
061       */
062      public Builder timeout(Duration value) {
063         timeout = value == null ? Duration.ofSeconds(1) : value;
064         return this;
065      }
066
067      /**
068       * Builds settings.
069       *
070       * @return Settings.
071       */
072      public HealthProbeSettings build() {
073         return new HealthProbeSettings(this);
074      }
075   }
076}