aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/main/java/com/yahoo/documentapi/SyncParameters.java
blob: 889172e082af7bdf94255f0fcf1a21a8c1b1adfa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi;

import java.time.Duration;
import java.util.Optional;

/**
 * Parameters for creating a synchronous session
 *
 * @author bjorncs
 * @author Simon Thoresen Hult
 */
public class SyncParameters extends Parameters {

    private final Duration defaultTimeout;

    private SyncParameters() {
        this(null);
    }

    private SyncParameters(Duration defaultTimeout) {
        this.defaultTimeout = defaultTimeout;
    }

    public Optional<Duration> defaultTimeout() {
        return Optional.ofNullable(defaultTimeout);
    }

    public static class Builder {

        private Duration defaultTimeout;

        /** @deprecated use {@link #defaultTimeout} */
        @Deprecated // TODO: Remove on Vespa 9
        public void setDefaultTimeout(Duration defaultTimeout) {
            defaultTimeout(defaultTimeout);
        }

        /** Set default timeout for all messagebus operations. */
        public Builder defaultTimeout(Duration defaultTimeout) {
            this.defaultTimeout = defaultTimeout;
            return this;
        }

        public SyncParameters build() {
            return new SyncParameters(defaultTimeout);
        }
    }

}