Class: FDK::Context
- Inherits:
-
Object
- Object
- FDK::Context
- Defined in:
- lib/fdk/context.rb
Overview
Represents the Fn context for a function execution
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
FN_APP_ID -the ID of the application that this function is a member of.
-
#response_headers ⇒ Object
readonly
Returns the value of attribute response_headers.
Instance Method Summary collapse
- #app_id ⇒ Object
- #call_id ⇒ Object
- #content_type ⇒ Object
- #deadline ⇒ Object
- #fn_id ⇒ Object
- #http_context ⇒ Object
-
#initialize(headers_in, headers_out) ⇒ Context
constructor
A new instance of Context.
- #memory ⇒ Object
Constructor Details
#initialize(headers_in, headers_out) ⇒ Context
Returns a new instance of Context.
68 69 70 71 72 |
# File 'lib/fdk/context.rb', line 68 def initialize(headers_in, headers_out) @headers = headers_in @response_headers = headers_out @config ||= Config.new end |
Instance Attribute Details
#headers ⇒ Object (readonly)
FN_APP_ID -the ID of the application that this function is a member of. FN_APP_NAME - the name of the application. FN_CALL_ID - a unique ID for each function execution. FN_FN_ID - the ID of this function FN_MEMORY - a number representing the amount of memory available to the call, in MB $X - any configuration values you’ve set for the Application.
Replace X with the upper cased name of the config variable you set.
e.g. minio_secret=secret will be exposed via MINIO_SECRET env var.
65 66 67 |
# File 'lib/fdk/context.rb', line 65 def headers @headers end |
#response_headers ⇒ Object (readonly)
Returns the value of attribute response_headers.
66 67 68 |
# File 'lib/fdk/context.rb', line 66 def response_headers @response_headers end |
Instance Method Details
#app_id ⇒ Object
78 79 80 |
# File 'lib/fdk/context.rb', line 78 def app_id @config["FN_APP_ID"] end |
#call_id ⇒ Object
74 75 76 |
# File 'lib/fdk/context.rb', line 74 def call_id @headers["fn-call-id"] end |
#content_type ⇒ Object
94 95 96 |
# File 'lib/fdk/context.rb', line 94 def content_type @headers["content-type"] end |
#deadline ⇒ Object
86 87 88 |
# File 'lib/fdk/context.rb', line 86 def deadline DateTime.iso8601(@headers["fn-deadline"]) end |
#fn_id ⇒ Object
82 83 84 |
# File 'lib/fdk/context.rb', line 82 def fn_id @config["FN_FN_ID"] end |
#http_context ⇒ Object
98 99 100 |
# File 'lib/fdk/context.rb', line 98 def http_context HTTPContext.new(self) end |
#memory ⇒ Object
90 91 92 |
# File 'lib/fdk/context.rb', line 90 def memory @config["FN_MEMORY"].to_i end |