Class: FDK::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/fdk/context.rb

Overview

Represents the Fn context for a function execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers_in, headers_out) ⇒ Context

Returns a new instance of Context.



87
88
89
90
91
# File 'lib/fdk/context.rb', line 87

def initialize(headers_in, headers_out)
  @headers = headers_in
  @response_headers = headers_out
  @config ||= Config.new
end

Instance Attribute Details

#headersObject (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.


85
86
87
# File 'lib/fdk/context.rb', line 85

def headers
  @headers
end

#response_headersObject (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.


85
86
87
# File 'lib/fdk/context.rb', line 85

def response_headers
  @response_headers
end

Instance Method Details

#app_idObject



97
98
99
# File 'lib/fdk/context.rb', line 97

def app_id
  @config["FN_APP_ID"]
end

#call_idObject



93
94
95
# File 'lib/fdk/context.rb', line 93

def call_id
  @headers["fn-call-id"]
end

#content_typeObject



113
114
115
# File 'lib/fdk/context.rb', line 113

def content_type
  @headers["content-type"]
end

#deadlineObject



105
106
107
# File 'lib/fdk/context.rb', line 105

def deadline
  DateTime.iso8601(@headers["fn-deadline"])
end

#fn_idObject



101
102
103
# File 'lib/fdk/context.rb', line 101

def fn_id
  @config["FN_FN_ID"]
end

#http_contextObject



117
118
119
# File 'lib/fdk/context.rb', line 117

def http_context
  HTTPContext.new(self)
end

#memoryObject



109
110
111
# File 'lib/fdk/context.rb', line 109

def memory
  @config["FN_MEMORY"].to_i
end