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.



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

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


65
66
67
# File 'lib/fdk/context.rb', line 65

def headers
  @headers
end

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



78
79
80
# File 'lib/fdk/context.rb', line 78

def app_id
  @config["FN_APP_ID"]
end

#call_idObject



74
75
76
# File 'lib/fdk/context.rb', line 74

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

#content_typeObject



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

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

#deadlineObject



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

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

#fn_idObject



82
83
84
# File 'lib/fdk/context.rb', line 82

def fn_id
  @config["FN_FN_ID"]
end

#http_contextObject



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

def http_context
  HTTPContext.new(self)
end

#memoryObject



90
91
92
# File 'lib/fdk/context.rb', line 90

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