Class: Wurk::ProfileRecord
- Inherits:
-
Object
- Object
- Wurk::ProfileRecord
- Defined in:
- lib/wurk/profile_set.rb
Overview
One profile record: the metadata fields of a <token>-<jid> HASH plus
lazy access to the gzipped gecko blob. Spec ยง19.8.
Instance Attribute Summary collapse
-
#elapsed ⇒ Object
readonly
Returns the value of attribute elapsed.
-
#jid ⇒ Object
readonly
Returns the value of attribute jid.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.data_for(key) ⇒ Object
Fetch the stored gzipped blob for a profile storage key ("
- ") straight from Redis, without materializing the whole record โ the Profiles data endpoint streams it to the browser as-is.
Instance Method Summary collapse
-
#data ⇒ Object
The stored blob is gzipped gecko JSON.
-
#initialize(hash) ⇒ ProfileRecord
constructor
A new instance of ProfileRecord.
- #key ⇒ Object
- #started_at ⇒ Object
Constructor Details
#initialize(hash) ⇒ ProfileRecord
Returns a new instance of ProfileRecord.
57 58 59 60 61 62 63 64 |
# File 'lib/wurk/profile_set.rb', line 57 def initialize(hash) @hash = hash @jid = hash['jid'] @type = hash['type'] @token = hash['token'] @size = hash['size'].to_i @elapsed = hash['elapsed'].to_i end |
Instance Attribute Details
#elapsed ⇒ Object (readonly)
Returns the value of attribute elapsed.
47 48 49 |
# File 'lib/wurk/profile_set.rb', line 47 def elapsed @elapsed end |
#jid ⇒ Object (readonly)
Returns the value of attribute jid.
47 48 49 |
# File 'lib/wurk/profile_set.rb', line 47 def jid @jid end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
47 48 49 |
# File 'lib/wurk/profile_set.rb', line 47 def size @size end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
47 48 49 |
# File 'lib/wurk/profile_set.rb', line 47 def token @token end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
47 48 49 |
# File 'lib/wurk/profile_set.rb', line 47 def type @type end |
Class Method Details
.data_for(key) ⇒ Object
Fetch the stored gzipped blob for a profile storage key ("data HASH-field name so web callers don't hardcode the schema.
53 54 55 |
# File 'lib/wurk/profile_set.rb', line 53 def self.data_for(key) Wurk.redis { |conn| conn.call('HGET', key, 'data') } end |
Instance Method Details
#data ⇒ Object
The stored blob is gzipped gecko JSON. data returns the raw (gzipped)
bytes โ the web layer streams them straight to the browser with a gzip
Content-Encoding. Returns nil if the HASH expired between list and read.
76 77 78 |
# File 'lib/wurk/profile_set.rb', line 76 def data self.class.data_for(key) end |
#key ⇒ Object
71 |
# File 'lib/wurk/profile_set.rb', line 71 def key = Wurk::Profiler.profile_key(@token, @jid) |
#started_at ⇒ Object
66 67 68 69 |
# File 'lib/wurk/profile_set.rb', line 66 def started_at ts = @hash['started_at'] ::Time.at(ts.to_i) unless ts.nil? || ts.empty? end |