Skip to content
This repository was archived by the owner on Mar 13, 2021. It is now read-only.

Kotlin support #283

Closed
sdeleuze opened this issue Feb 16, 2018 · 5 comments
Closed

Kotlin support #283

sdeleuze opened this issue Feb 16, 2018 · 5 comments

Comments

@sdeleuze
Copy link

Hey, I would be interested to contribute Kotlin support to Riff. This support would be based on the upcoming Kotlin Scripting support improvements which is designed to overcome current limitations (no imports, no caching between execution) and should allow to target various platforms (JVM and Native) in a consistent way.

Prototypes of this new support seems to be around the corner, if it takes too much time we may do some progress using kscript potentially.

Supporting Kotlin/JVM via the current Java Riff support is possible and maybe already works since it is equivalent to Java in term of packaging, so it could be low hanging fruit for the short term. I will check if that works or not. But I do think Kotlin Scripting enhanced support will be a much more suitable foundation for Riff support.

Any thoughts or interest about this topic?

@jldec
Copy link
Contributor

jldec commented Feb 17, 2018

Definitely interested - thanks @sdeleuze!

cc @ericbottard @dsyer @markfisher

@apatrida
Copy link

Have you looked at using Kotlin Lambda's as functions (You could also do this with Java Lambdas)? You do not need scripting, you can serialize the Lambda to a form that can be shipped, added to a sidecar and executed (and securely as well against white-listed methods).

See:
https://github.com/kohesive/chillambda (serializing Lambda's from client code as scripts)
https://github.com/kohesive/cuarentena (security of code via bytecode analysis)

And an example usage as binary scripts in Elasticsearch:
https://github.com/kohesive/elasticsearch-lang-kotlin

There was also an experiment done where a generic AWS Lambda was created, that could run scripts based on their desired context, the context deciding what access they were allowed via a predefined API and security rules. Then the client code would just send a message that included the Kotlin lambda and it would be verified and executed by the AWS Lambda as the message passed by. This allowed queuing of data + functions to be executed at any scale. Then this was tried to basically have a Lambda that merged incoming data with predefined "binary scripts" (Kotlin serialized Lambdas) and pass along to the executor function, so that only the data was sent by clients, merged with the lambda, and executed at scale.

I'm the maintainer of the projects and they are nearing release, along with more samples. So if there is interest, let's see how they could work here.

@sdeleuze
Copy link
Author

Thanks @apatrida, I was not aware of these interesting capabilities. That's said, we are probably going to start with something simpler but I will contact you after that to explore your proposal for scripting support.

After more thoughts, my proposal is to start simple by Kotlin/JVM support on java-function-invoker, I have created projectriff/java-function-invoker#81 with more details.

After that, I would like to have a deeper look on the options to support Kotlin/Native, and explore the following points:

@sdeleuze
Copy link
Author

sdeleuze commented May 22, 2018

As discussed on projectriff/java-function-invoker#81, I am going to work on a kotlin-function-invoker dedicated project that will as a first step:

  • Use java-function-invoker as a library + kotlin-runtime to provide Kotlin/JVM support
  • Support Kotlin function types (class Greeter : (String) -> String as a more idiomatic alternative to class Greeter : Function<String, String>)
  • Support Kotlin top level functions like go-function-invoker supports them

When that will work, I would like to explore Kotlin/Native support (as described in my previous comment) and scripting support.

@fbiville
Copy link
Contributor

The current plan to support other languages is best described in #1093. Feel free to comment there for further discussion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants