Class: Trifle::Stats::Driver::Api
- Inherits:
-
Object
- Object
- Trifle::Stats::Driver::Api
show all
- Defined in:
- lib/trifle/stats/driver/api.rb
Defined Under Namespace
Classes: Error, NetHttpTransport
Constant Summary
collapse
- ENDPOINT =
URI('https://app.trifle.io/api/v1/metrics')
- TIMEOUT =
10
- ERROR_BODY_LIMIT =
1024
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(token:, project_id:, transport: NetHttpTransport.new) ⇒ Api
Returns a new instance of Api.
45
46
47
48
49
50
51
52
|
# File 'lib/trifle/stats/driver/api.rb', line 45
def initialize(token:, project_id:, transport: NetHttpTransport.new)
raise ArgumentError, 'token must not be empty' if token.to_s.strip.empty?
raise ArgumentError, 'project_id must not be empty' if project_id.to_s.strip.empty?
@token = token.to_s
@project_id = project_id.to_s
@transport = transport
end
|
Instance Attribute Details
#project_id ⇒ Object
Returns the value of attribute project_id.
43
44
45
|
# File 'lib/trifle/stats/driver/api.rb', line 43
def project_id
@project_id
end
|
#token ⇒ Object
Returns the value of attribute token.
43
44
45
|
# File 'lib/trifle/stats/driver/api.rb', line 43
def token
@token
end
|
Instance Method Details
#bypass_buffer? ⇒ Boolean
58
59
60
|
# File 'lib/trifle/stats/driver/api.rb', line 58
def bypass_buffer?
true
end
|
#description ⇒ Object
54
55
56
|
# File 'lib/trifle/stats/driver/api.rb', line 54
def description
self.class.name
end
|
#direct_write(operation:, key:, at:, values:, untracked: false) ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/trifle/stats/driver/api.rb', line 62
def direct_write(operation:, key:, at:, values:, untracked: false)
payload = api_payload(operation, key, at, values, untracked)
deliver(build_request(payload))
rescue Error
raise
rescue StandardError => e
raise Error.new("Trifle API request failed: #{e.message}", delivery_unknown: true), cause: e
end
|
#get ⇒ Object
79
80
81
|
# File 'lib/trifle/stats/driver/api.rb', line 79
def get(*)
unsupported!(:values)
end
|
#inc ⇒ Object
71
72
73
|
# File 'lib/trifle/stats/driver/api.rb', line 71
def inc(*)
unsupported!(:track)
end
|
#ping ⇒ Object
83
84
85
|
# File 'lib/trifle/stats/driver/api.rb', line 83
def ping(*)
unsupported!(:beam)
end
|
#scan ⇒ Object
87
88
89
|
# File 'lib/trifle/stats/driver/api.rb', line 87
def scan(*)
unsupported!(:scan)
end
|
#set ⇒ Object
75
76
77
|
# File 'lib/trifle/stats/driver/api.rb', line 75
def set(*)
unsupported!(:assert)
end
|