|
| 1 | +// |
| 2 | +// DISCLAIMER |
| 3 | +// |
| 4 | +// Copyright 2025 ArangoDB GmbH, Cologne, Germany |
| 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 | +// Copyright holder is ArangoDB GmbH, Cologne, Germany |
| 19 | +// |
| 20 | + |
| 21 | +package gateway |
| 22 | + |
| 23 | +import ( |
| 24 | + "time" |
| 25 | + |
| 26 | + pbEnvoyCoreV3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" |
| 27 | + "google.golang.org/protobuf/types/known/durationpb" |
| 28 | + |
| 29 | + shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" |
| 30 | + "github.com/arangodb/kube-arangodb/pkg/util" |
| 31 | +) |
| 32 | + |
| 33 | +type ConfigDestinationHealthChecks []ConfigDestinationHealthCheck |
| 34 | + |
| 35 | +func (c ConfigDestinationHealthChecks) Validate() error { |
| 36 | + return shared.ValidateInterfaceList(c) |
| 37 | +} |
| 38 | + |
| 39 | +func (c ConfigDestinationHealthChecks) Render() []*pbEnvoyCoreV3.HealthCheck { |
| 40 | + ret := make([]*pbEnvoyCoreV3.HealthCheck, len(c)) |
| 41 | + for id := range c { |
| 42 | + ret[id] = c[id].Render() |
| 43 | + } |
| 44 | + return ret |
| 45 | +} |
| 46 | + |
| 47 | +type ConfigDestinationHealthCheck struct { |
| 48 | + Timeout *time.Duration `json:"timeout,omitempty"` |
| 49 | + |
| 50 | + Interval *time.Duration `json:"interval,omitempty"` |
| 51 | +} |
| 52 | + |
| 53 | +func (c ConfigDestinationHealthCheck) Validate() error { |
| 54 | + return nil |
| 55 | +} |
| 56 | + |
| 57 | +func (c ConfigDestinationHealthCheck) Render() *pbEnvoyCoreV3.HealthCheck { |
| 58 | + return &pbEnvoyCoreV3.HealthCheck{ |
| 59 | + Timeout: durationpb.New(util.OptionalType(c.Timeout, time.Second)), |
| 60 | + Interval: durationpb.New(util.OptionalType(c.Interval, time.Second)), |
| 61 | + |
| 62 | + HealthChecker: &pbEnvoyCoreV3.HealthCheck_TcpHealthCheck_{ |
| 63 | + TcpHealthCheck: &pbEnvoyCoreV3.HealthCheck_TcpHealthCheck{}, |
| 64 | + }, |
| 65 | + } |
| 66 | +} |
0 commit comments