|
| 1 | +// |
| 2 | +// DISCLAIMER |
| 3 | +// |
| 4 | +// Copyright 2023 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 conn |
| 22 | + |
| 23 | +import ( |
| 24 | + "context" |
| 25 | + |
| 26 | + "github.com/arangodb/go-driver" |
| 27 | +) |
| 28 | + |
| 29 | +func NewClosedConnection() driver.Connection { |
| 30 | + return closedConnection{} |
| 31 | +} |
| 32 | + |
| 33 | +func newClosedConnectionError() error { |
| 34 | + return closedConnectionError{} |
| 35 | +} |
| 36 | + |
| 37 | +type closedConnectionError struct { |
| 38 | +} |
| 39 | + |
| 40 | +func (c closedConnectionError) Error() string { |
| 41 | + return "Connection Closed" |
| 42 | +} |
| 43 | + |
| 44 | +type closedConnection struct { |
| 45 | +} |
| 46 | + |
| 47 | +func (c closedConnection) NewRequest(method, path string) (driver.Request, error) { |
| 48 | + return nil, newClosedConnectionError() |
| 49 | +} |
| 50 | + |
| 51 | +func (c closedConnection) Do(ctx context.Context, req driver.Request) (driver.Response, error) { |
| 52 | + return nil, newClosedConnectionError() |
| 53 | +} |
| 54 | + |
| 55 | +func (c closedConnection) Unmarshal(data driver.RawObject, result interface{}) error { |
| 56 | + return newClosedConnectionError() |
| 57 | +} |
| 58 | + |
| 59 | +func (c closedConnection) Endpoints() []string { |
| 60 | + return nil |
| 61 | +} |
| 62 | + |
| 63 | +func (c closedConnection) UpdateEndpoints(endpoints []string) error { |
| 64 | + return newClosedConnectionError() |
| 65 | +} |
| 66 | + |
| 67 | +func (c closedConnection) SetAuthentication(authentication driver.Authentication) (driver.Connection, error) { |
| 68 | + return c, nil |
| 69 | +} |
| 70 | + |
| 71 | +func (c closedConnection) Protocols() driver.ProtocolSet { |
| 72 | + return nil |
| 73 | +} |
0 commit comments