b8b700228fc5162be1ae360412689c9b3419858a
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / nb / rfc8040 / streams / StreamsConfiguration.java
1 /*
2  * Copyright © 2019 FRINX s.r.o. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.nb.rfc8040.streams;
9
10 import static com.google.common.base.Preconditions.checkArgument;
11
12 /**
13  * RESTCONF configuration holder and verifier.
14  *
15  * @param maximumFragmentLength Maximum web-socket fragment length in number of Unicode code units (characters)
16  *                              (exceeded message length leads to fragmentation of messages).
17  * @param idleTimeout           Maximum idle time of web-socket session before the session is closed (milliseconds).
18  * @param heartbeatInterval     Interval in milliseconds between sending of ping control frames.
19  * @param useSSE                when is {@code true} use SSE else use WS
20  */
21 public record StreamsConfiguration(int maximumFragmentLength, int idleTimeout, int heartbeatInterval, boolean useSSE) {
22     public StreamsConfiguration {
23         checkArgument(maximumFragmentLength >= 0 && maximumFragmentLength < 65535,
24             "Maximum fragment length must be disabled (0) or specified by positive value less than 64KiB");
25         checkArgument(idleTimeout > 0, "Idle timeout must be specified by positive value.");
26         checkArgument(heartbeatInterval >= 0,
27             "Heartbeat ping interval must be disabled (0) or specified by positive value.");
28     }
29 }