Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Interoperability with Go

Interoperability with Go

Matias Insaurralde

January 21, 2017
Tweet

More Decks by Matias Insaurralde

Other Decks in Technology

Transcript

  1. About me - I work on Tyk (tyk.io), an open

    source API gateway written in Go.
 - I’m 22 years old and I live in Paraguay, a small country in the heart of South America. - Wrote my first program when I was 10 years old.
 - I like pasta :)
  2. Looking at cgo - How to make it easier to

    integrate new language runtimes?
 - A lot of language runtimes are embeddable and have nice APIs for that.
 - In-process request passing. - “Mapping” our http.Request to C structs (and passing them) makes sense, but it’s hard to maintain, we also need to pass session objects (lot of fields and nested structures). - We decided to use Protocol Buffers, it has a significant overhead but makes it maintainable.
  3. Let’s try Python! - CPython is easy to embed. -

    We combined this with Cython-generated modules (loaded with cgo!). - A few disadvantages…
  4. LuaJIT - We did a LuaJIT integration.
 - No official

    Protocol Buffers modules for Lua :(

  5. A few notes - Serialization made things easier, but involves

    copying data structures. We’re in the process of optimizing this.
 - We did a lot of benchmarks, LuaJIT is able to handle a lot more requests per second than the rest of the embedded runtimes.
 - I find the Protocol Buffers + cgo combination very powerful.
 - Go 1.8 “plugins” will give us a lot of possibilities.
  6. - Last year I wrote a quick PoC called “go-dotnet”.


    - .NET has a CLR “Hosting API”, I didn’t find enough documentation about it.
 - The PoC uses the CLR Hosting API, and it does a very simple thing (from Go): loads an assembly file (DLL) and calls a .NET function. go-dotnet
  7. - You may find the code here:
 http://tinyurl.com/go-dotnet
 - I’m

    working on the code generation approach, and would like to turn the PoC into an useful package. - Interesting things to try: serve ASP.NET apps with net/ http :p go-dotnet
  8. The end Thanks!
 
 You may find me here:
 


    Github: https://github.com/matiasinsaurralde
 Twitter: https://twitter.com/matias_baruch
 E-mail: matias@insaurral.de