Skip to content

Commit baee6a4

Browse files
authored
OAS-10311 Remove deprecated context functions (#639)
1 parent fb2ca10 commit baee6a4

File tree

4 files changed

+1
-62
lines changed

4 files changed

+1
-62
lines changed

v2/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Connection configuration helper
66
- Adjust Cursor options
77
- Switch to Go 1.22.8
8+
- Remove deprecated context functions
89

910
## [2.1.1](https://github.com/arangodb/go-driver/tree/v2.1.1) (2024-09-27)
1011
- Improve backup tests stability

v2/connection/call.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func CallWithChecks(ctx context.Context, c Connection, method, url string, outpu
3939
return nil, err
4040
}
4141

42-
modifiers = append(modifiers, applyGlobalSettings(ctx))
4342
modifiers = append(modifiers, applyArangoDBConfiguration(c.GetConfiguration(), ctx))
4443

4544
for _, modifier := range modifiers {
@@ -60,7 +59,6 @@ func CallStream(ctx context.Context, c Connection, method, url string, modifiers
6059
return nil, nil, err
6160
}
6261

63-
modifiers = append(modifiers, applyGlobalSettings(ctx))
6462
modifiers = append(modifiers, applyArangoDBConfiguration(c.GetConfiguration(), ctx))
6563

6664
for _, modifier := range modifiers {

v2/connection/context.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,11 @@ package connection
2222

2323
import (
2424
"context"
25-
"time"
2625
)
2726

2827
type ContextKey string
2928

3029
const (
31-
keyUseQueueTimeout ContextKey = "arangodb-use-queue-timeout"
32-
keyMaxQueueTime ContextKey = "arangodb-max-queue-time-seconds"
33-
keyDriverFlags ContextKey = "arangodb-driver-flags"
34-
3530
keyAsyncRequest ContextKey = "arangodb-async-request"
3631
keyAsyncID ContextKey = "arangodb-async-id"
3732
)
@@ -45,25 +40,6 @@ func contextOrBackground(ctx context.Context) context.Context {
4540
return context.Background()
4641
}
4742

48-
// WithArangoQueueTimeout is used to enable Queue timeout on the server side.
49-
// If WithArangoQueueTime is used, then its value takes precedence in other case value of ctx.Deadline will be taken
50-
// Deprecated: use ArangoDBConfiguration.ArangoQueueTimeoutEnabled
51-
func WithArangoQueueTimeout(parent context.Context, useQueueTimeout bool) context.Context {
52-
return context.WithValue(contextOrBackground(parent), keyUseQueueTimeout, useQueueTimeout)
53-
}
54-
55-
// WithArangoQueueTime defines max queue timeout on the server side.
56-
// Deprecated: use ArangoDBConfiguration.ArangoQueueTimeoutSec
57-
func WithArangoQueueTime(parent context.Context, duration time.Duration) context.Context {
58-
return context.WithValue(contextOrBackground(parent), keyMaxQueueTime, duration)
59-
}
60-
61-
// WithDriverFlags is used to configure additional flags for the `x-arango-driver` header.
62-
// Deprecated: use ArangoDBConfiguration.DriverFlags
63-
func WithDriverFlags(parent context.Context, value []string) context.Context {
64-
return context.WithValue(contextOrBackground(parent), keyDriverFlags, value)
65-
}
66-
6743
// WithAsync is used to configure a context to make an async operation - requires Connection with Async wrapper!
6844
func WithAsync(parent context.Context) context.Context {
6945
return context.WithValue(contextOrBackground(parent), keyAsyncRequest, true)

v2/connection/modifiers.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -50,42 +50,6 @@ func WithQuery(s, value string) RequestModifier {
5050
}
5151
}
5252

53-
// applyGlobalSettings applies the settings configured in the context to the given request.
54-
// Deprecated: use applyArangoDBConfiguration instead
55-
func applyGlobalSettings(ctx context.Context) RequestModifier {
56-
return func(r Request) error {
57-
58-
// Set version header
59-
val := fmt.Sprintf("go-driver-v2/%s", version.DriverVersion())
60-
if ctx != nil {
61-
if v := ctx.Value(keyDriverFlags); v != nil {
62-
if flags, ok := v.([]string); ok {
63-
val = fmt.Sprintf("%s (%s)", val, strings.Join(flags, ","))
64-
}
65-
}
66-
}
67-
r.AddHeader("x-arango-driver", val)
68-
69-
// Enable Queue timeout
70-
if ctx != nil {
71-
if v := ctx.Value(keyUseQueueTimeout); v != nil {
72-
if useQueueTimeout, ok := v.(bool); ok && useQueueTimeout {
73-
if v := ctx.Value(keyMaxQueueTime); v != nil {
74-
if timeout, ok := v.(time.Duration); ok {
75-
r.AddHeader("x-arango-queue-time-seconds", fmt.Sprint(timeout.Seconds()))
76-
}
77-
} else if deadline, ok := ctx.Deadline(); ok {
78-
timeout := deadline.Sub(time.Now())
79-
r.AddHeader("x-arango-queue-time-seconds", fmt.Sprint(timeout.Seconds()))
80-
}
81-
}
82-
}
83-
}
84-
85-
return nil
86-
}
87-
}
88-
8953
func applyArangoDBConfiguration(config ArangoDBConfiguration, ctx context.Context) RequestModifier {
9054
return func(r Request) error {
9155
// Set version header

0 commit comments

Comments
 (0)