|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +package org.apache.polaris.async; |
| 20 | + |
| 21 | +import com.fasterxml.jackson.annotation.JsonFormat; |
| 22 | +import com.fasterxml.jackson.annotation.JsonInclude; |
| 23 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
| 24 | +import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| 25 | +import io.smallrye.config.ConfigMapping; |
| 26 | +import io.smallrye.config.WithDefault; |
| 27 | +import java.time.Duration; |
| 28 | +import java.util.Optional; |
| 29 | +import java.util.OptionalInt; |
| 30 | +import org.apache.polaris.immutables.PolarisImmutable; |
| 31 | + |
| 32 | +/** Advanced configuration options to tune async activities. */ |
| 33 | +@PolarisImmutable |
| 34 | +@ConfigMapping(prefix = "polaris.async") |
| 35 | +@JsonSerialize(as = ImmutableAsyncConfiguration.class) |
| 36 | +@JsonDeserialize(as = ImmutableAsyncConfiguration.class) |
| 37 | +public interface AsyncConfiguration { |
| 38 | + |
| 39 | + String DEFAULT_THREAD_KEEP_ALIVE_STRING = "PT1S"; |
| 40 | + Duration DEFAULT_THREAD_KEEP_ALIVE = Duration.parse(DEFAULT_THREAD_KEEP_ALIVE_STRING); |
| 41 | + |
| 42 | + /** Duration to keep idle threads alive. */ |
| 43 | + @WithDefault(DEFAULT_THREAD_KEEP_ALIVE_STRING) |
| 44 | + @JsonInclude(JsonInclude.Include.NON_ABSENT) |
| 45 | + @JsonFormat(shape = JsonFormat.Shape.STRING) |
| 46 | + Optional<Duration> threadKeepAlive(); |
| 47 | + |
| 48 | + /** Maximum number of threads available for asynchronous execution. Default is unlimited. */ |
| 49 | + @JsonInclude(JsonInclude.Include.NON_ABSENT) |
| 50 | + OptionalInt maxThreads(); |
| 51 | + |
| 52 | + static ImmutableAsyncConfiguration.Builder builder() { |
| 53 | + return ImmutableAsyncConfiguration.builder(); |
| 54 | + } |
| 55 | +} |
0 commit comments