Skip to content

Commit 0f78cf7

Browse files
committed
DEBUG-3535 DRY transport Instance and Spec classes
1 parent 917747b commit 0f78cf7

File tree

19 files changed

+72
-158
lines changed

19 files changed

+72
-158
lines changed

lib/datadog/core/remote/transport/http.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
# require_relative '../../transport/http/api'
2121
require_relative 'http/api'
2222

23-
require_relative 'http/api/instance'
24-
2523
# TODO: Decouple transport/http
2624
#
2725
# Because a new transport is required for every (API, Client, Transport)

lib/datadog/core/remote/transport/http/api.rb

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,9 @@
22

33
require_relative '../../../encoding'
44
require_relative '../../../transport/http/api/map'
5-
6-
# TODO: Decouple standard transport/http/api/instance
7-
#
8-
# Separate classes are needed because transport/http/traces includes
9-
# Trace::API::Instance which closes over and uses a single spec, which is
10-
# negotiated as either /v3 or /v4 for the whole API at the spec level, but we
11-
# need an independent toplevel path at the endpoint level.
12-
#
13-
# Separate classes are needed because of `include Trace::API::Instance`.
14-
#
15-
# Below should be:
16-
# require_relative '../../../../datadog/core/transport/http/api/spec'
17-
require_relative 'api/spec'
18-
19-
# TODO: only needed for Negotiation::API::Endpoint
5+
require_relative '../../../transport/http/api/instance'
6+
require_relative '../../../transport/http/api/spec'
207
require_relative 'negotiation'
21-
22-
# TODO: only needed for Config::API::Endpoint
238
require_relative 'config'
249

2510
module Datadog
@@ -36,7 +21,7 @@ module API
3621
module_function
3722

3823
def defaults
39-
Datadog::Core::Transport::HTTP::API::Map[
24+
Core::Transport::HTTP::API::Map[
4025
ROOT => Spec.new do |s|
4126
s.info = Negotiation::API::Endpoint.new(
4227
'/info',
@@ -50,6 +35,16 @@ def defaults
5035
end,
5136
]
5237
end
38+
39+
class Instance < Core::Transport::HTTP::API::Instance
40+
include Config::API::Instance
41+
include Negotiation::API::Instance
42+
end
43+
44+
class Spec < Core::Transport::HTTP::API::Spec
45+
include Config::API::Spec
46+
include Negotiation::API::Spec
47+
end
5348
end
5449
end
5550
end

lib/datadog/core/remote/transport/http/api/instance.rb

Lines changed: 0 additions & 39 deletions
This file was deleted.

lib/datadog/core/remote/transport/http/api/spec.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.

lib/datadog/core/remote/transport/http/config.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,6 @@
88
require_relative '../../../transport/http/response'
99
require_relative '../../../transport/http/api/endpoint'
1010

11-
# TODO: Decouple standard transport/http/api/instance
12-
#
13-
# Separate classes are needed because transport/http/trace includes
14-
# Trace::API::Instance which closes over and uses a single spec, which is
15-
# negotiated as either /v3 or /v4 for the whole API at the spec level, but we
16-
# need an independent toplevel path at the endpoint level.
17-
#
18-
# Separate classes are needed because of `include Trace::API::Instance`.
19-
#
20-
# Below should be:
21-
# require_relative '../../../core/transport/http/api/instance'
22-
require_relative 'api/instance'
23-
# Below should be:
24-
# require_relative '../../../core/transport/http/api/spec'
25-
require_relative 'api/spec'
26-
2711
module Datadog
2812
module Core
2913
module Remote
@@ -270,8 +254,6 @@ def call(env, &block)
270254
# Add remote configuration behavior to transport components
271255
###### overrides send_payload! which calls send_<endpoint>! kills any other possible endpoint!
272256
HTTP::Client.include(Config::Client)
273-
HTTP::API::Spec.include(Config::API::Spec)
274-
HTTP::API::Instance.include(Config::API::Instance)
275257
end
276258
end
277259
end

lib/datadog/core/remote/transport/http/negotiation.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,6 @@
77
require_relative '../../../transport/http/response'
88
require_relative '../../../transport/http/api/endpoint'
99

10-
# TODO: Decouple standard transport/http/api/instance
11-
#
12-
# Separate classes are needed because transport/http/trace includes
13-
# Trace::API::Instance which closes over and uses a single spec, which is
14-
# negotiated as either /v3 or /v4 for the whole API at the spec level, but we
15-
# need an independent toplevel path at the endpoint level.
16-
#
17-
# Separate classes are needed because of `include Trace::API::Instance`.
18-
#
19-
# Below should be:
20-
# require_relative '../../../../datadog/core/transport/http/api/instance'
21-
require_relative 'api/instance'
22-
# Below should be:
23-
# require_relative '../../../../datadog/core/transport/http/api/spec'
24-
require_relative 'api/spec'
25-
2610
module Datadog
2711
module Core
2812
module Remote
@@ -137,8 +121,6 @@ def call(env, &block)
137121

138122
# Add negotiation behavior to transport components
139123
HTTP::Client.include(Negotiation::Client)
140-
HTTP::API::Spec.include(Negotiation::API::Spec)
141-
HTTP::API::Instance.include(Negotiation::API::Instance)
142124
end
143125
end
144126
end

lib/datadog/tracing/transport/http/api/instance.rb renamed to lib/datadog/core/transport/http/api/instance.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module Datadog
4-
module Tracing
4+
module Core
55
module Transport
66
module HTTP
77
module API

lib/datadog/tracing/transport/http/api/spec.rb renamed to lib/datadog/core/transport/http/api/spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module Datadog
4-
module Tracing
4+
module Core
55
module Transport
66
module HTTP
77
module API

lib/datadog/tracing/transport/http.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
require_relative '../../core/transport/http/adapters/unix_socket'
1111
require_relative '../../core/transport/http/builder'
1212
require_relative 'http/api'
13-
require_relative 'http/api/instance'
1413
require_relative '../../../datadog/version'
1514

1615
module Datadog

lib/datadog/tracing/transport/http/api.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
require_relative '../../../core/encoding'
44

55
require_relative '../../../core/transport/http/api/map'
6-
require_relative 'api/spec'
6+
require_relative '../../../core/transport/http/api/instance'
7+
require_relative '../../../core/transport/http/api/spec'
78

89
require_relative 'traces'
910

@@ -20,7 +21,7 @@ module API
2021
module_function
2122

2223
def defaults
23-
Datadog::Core::Transport::HTTP::API::Map[
24+
Core::Transport::HTTP::API::Map[
2425
V4 => Spec.new do |s|
2526
s.traces = Traces::API::Endpoint.new(
2627
'/v0.4/traces',
@@ -36,6 +37,14 @@ def defaults
3637
end,
3738
].with_fallbacks(V4 => V3)
3839
end
40+
41+
class Instance < Core::Transport::HTTP::API::Instance
42+
include Traces::API::Instance
43+
end
44+
45+
class Spec < Core::Transport::HTTP::API::Spec
46+
include Traces::API::Spec
47+
end
3948
end
4049
end
4150
end

0 commit comments

Comments
 (0)