module FDK

Copyright © 2019, 2020 Oracle and/or its affiliates. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2019, 2020 Oracle and/or its affiliates. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2019, 2020 Oracle and/or its affiliates. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Looks for call(context, input) function Executes it with input Responds with output

Copyright © 2019, 2020 Oracle and/or its affiliates. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2019, 2020 Oracle and/or its affiliates. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Constants

FDK_LOG_DEBUG
FDK_LOG_DEFAULT
FDK_LOG_THRESHOLD
VERSION

Public Class Methods

debug(msg) click to toggle source
# File lib/fdk/runner.rb, line 47
def self.debug(msg)
  log(entry: msg, log_level: FDK_LOG_DEBUG)
end
handle(target:) click to toggle source
# File lib/fdk/runner.rb, line 51
def self.handle(target:)
  func = Function.new(function: target, format: ENV["FN_FORMAT"])
  Listener.new(url: ENV["FN_LISTENER"]).listen do |req, resp|
    func.call(request: req, response: resp)
  end
end
log(entry:, log_level: FDK_LOG_DEFAULT) click to toggle source

Writes the entry to STDERR if the log_level >= log_threshold If no log level is specified, 1 is assumed.

# File lib/fdk/runner.rb, line 38
def self.log(entry:, log_level: FDK_LOG_DEFAULT)
  warn(entry) if log_level >= log_threshold
end
log_error(error:) click to toggle source
# File lib/fdk/runner.rb, line 42
def self.log_error(error:)
  log(entry: error.message)
  log(entry: error.backtrace.join("\n"), log_level: FDK_LOG_DEBUG)
end
log_threshold() click to toggle source
# File lib/fdk/runner.rb, line 32
def self.log_threshold
  @log_threshold ||= ENV[FDK_LOG_THRESHOLD] ? ENV[FDK_LOG_THRESHOLD].to_i : FDK_LOG_DEFAULT
end