|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright 2014-Present Couchbase, Inc. |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * 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, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +declare(strict_types=1); |
| 20 | + |
| 21 | +namespace Couchbase; |
| 22 | + |
| 23 | +class AppTelemetryConfiguration |
| 24 | +{ |
| 25 | + private ?bool $enabled = null; |
| 26 | + private ?string $endpoint = null; |
| 27 | + private ?int $backoffMilliseconds = null; |
| 28 | + private ?int $pingIntervalMilliseconds = null; |
| 29 | + private ?int $pingTimeoutMilliseconds = null; |
| 30 | + |
| 31 | + /** |
| 32 | + * Specifies if the application telemetry feature should be enabled or not. |
| 33 | + * |
| 34 | + * @param bool $enabled |
| 35 | + * |
| 36 | + * @return AppTelemetryConfiguration |
| 37 | + * @since 4.5.0 |
| 38 | + */ |
| 39 | + public function enabled(bool $enabled): AppTelemetryConfiguration |
| 40 | + { |
| 41 | + $this->enabled = $enabled; |
| 42 | + return $this; |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Specifies an endpoint to override the application metrics endpoint discovered during configuration. |
| 47 | + * |
| 48 | + * @param string $endpoint |
| 49 | + * |
| 50 | + * @return AppTelemetryConfiguration |
| 51 | + * @since 4.5.0 |
| 52 | + */ |
| 53 | + public function endpoint(string $endpoint): AppTelemetryConfiguration |
| 54 | + { |
| 55 | + $this->endpoint = $endpoint; |
| 56 | + return $this; |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Specifies the time to wait before attempting a websocket reconnection, specified in millseconds. |
| 61 | + * |
| 62 | + * @param int $milliseconds |
| 63 | + * |
| 64 | + * @return AppTelemetryConfiguration |
| 65 | + * @since 4.5.0 |
| 66 | + */ |
| 67 | + public function backoff(int $milliseconds): AppTelemetryConfiguration |
| 68 | + { |
| 69 | + $this->backoffMilliseconds = $milliseconds; |
| 70 | + return $this; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Specifies the time to wait between sending consecutive websocket PING commands to the server, specified in millseconds. |
| 75 | + * |
| 76 | + * @param int $milliseconds |
| 77 | + * |
| 78 | + * @return AppTelemetryConfiguration |
| 79 | + * @since 4.5.0 |
| 80 | + */ |
| 81 | + public function pingInterval(int $milliseconds): AppTelemetryConfiguration |
| 82 | + { |
| 83 | + $this->pingIntervalMilliseconds = $milliseconds; |
| 84 | + return $this; |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * Specifies the time allowed for the server to respond to websocket PING command, specified in millseconds. |
| 89 | + * |
| 90 | + * @param int $milliseconds |
| 91 | + * |
| 92 | + * @return AppTelemetryConfiguration |
| 93 | + * @since 4.5.0 |
| 94 | + */ |
| 95 | + public function pingTimeout(int $milliseconds): AppTelemetryConfiguration |
| 96 | + { |
| 97 | + $this->pingTimeoutMilliseconds = $milliseconds; |
| 98 | + return $this; |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * @internal |
| 103 | + */ |
| 104 | + public function export(): array |
| 105 | + { |
| 106 | + return [ |
| 107 | + 'enabled' => $this->enabled, |
| 108 | + 'endpoint' => $this->endpoint, |
| 109 | + 'backoff' => $this->backoffMilliseconds, |
| 110 | + 'pingInterval' => $this->pingIntervalMilliseconds, |
| 111 | + 'pingTimeout' => $this->pingTimeoutMilliseconds, |
| 112 | + ]; |
| 113 | + } |
| 114 | +} |
0 commit comments