How to use the fdk.customer_code.Function function in fdk

To help you get started, we’ve selected a few fdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fnproject / fdk-python / fdk / __init__.py View on Github external
def handle(handle_code: customer_code.Function):
    """
    FDK entry point
    :param handle_code: customer's code
    :type handle_code: fdk.customer_code.Function
    :return: None
    """
    log.log("entering handle")
    if not isinstance(handle_code, customer_code.Function):
        sys.exit(
            '\n\n\nWARNING!\n\n'
            'Your code is not compatible the the latest FDK!\n\n'
            'Update Dockerfile entry point to:\n'
            'ENTRYPOINT["/python/bin/fdk", "", {0}]\n\n'
            'if __name__ == "__main__":\n\tfdk.handle(handler)\n\n'
            'syntax no longer supported!\n'
            'Update your code as soon as possible!'
            '\n\n\n'.format(handle_code.__name__))

    loop = asyncio.get_event_loop()

    format_def = os.environ.get(constants.FN_FORMAT)
    lsnr = os.environ.get(constants.FN_LISTENER)
    log.log("{0} is set, value: {1}".
            format(constants.FN_FORMAT, format_def))
github fnproject / fdk-python / fdk / scripts / fdk_tcp_debug.py View on Github external
def main():
    if len(sys.argv) < 3:
        print("Usage: fdk-tcp-debug   [entrypoint]")
        sys.exit("at least func module must be specified")

    if not os.path.exists(sys.argv[2]):
        sys.exit("Module: {0} doesn't exist".format(sys.argv[1]))

    if len(sys.argv) > 3:
        handler = customer_code.Function(
            sys.argv[2], entrypoint=sys.argv[3])
    else:
        handler = customer_code.Function(sys.argv[1])

    tcp_debug.handle(handler, port=int(sys.argv[1]))
github fnproject / fdk-python / fdk / scripts / fdk_tcp_debug.py View on Github external
def main():
    if len(sys.argv) < 3:
        print("Usage: fdk-tcp-debug   [entrypoint]")
        sys.exit("at least func module must be specified")

    if not os.path.exists(sys.argv[2]):
        sys.exit("Module: {0} doesn't exist".format(sys.argv[1]))

    if len(sys.argv) > 3:
        handler = customer_code.Function(
            sys.argv[2], entrypoint=sys.argv[3])
    else:
        handler = customer_code.Function(sys.argv[1])

    tcp_debug.handle(handler, port=int(sys.argv[1]))