3 ms·
Question if anyone from the Oso team is here: From what I've read, the Oso core is built in rust, but then is it called from Ruby or is it re-implemented in Rub
by xcskier56 5y ago
Question if anyone from the Oso team is here: From what I've read, the Oso core is built in rust, but then is it called from Ruby or is it re-implemented in Ruby? I couldn't see any native extension like code in the ruby portion of the repo but could easily have missed it.
- hobofan 5y agoIt is a wrapper around the Rust code: - It triggers the rust build in the Makefile: https://github.com/osohq/oso/blob/1d3bf5a4a997a574c2b19084a0d8c1a0d9cc91e6/languages/ruby/Makefile#L4 https://github.com/osohq/oso/blob/1d3bf5a4a997a574c2b19084a0... - There is a bunch of FFI code (also in the ffi directory): https://github.com/osohq/oso/blob/1d3bf5a4a997a574c2b19084a0d8c1a0d9cc91e6/languages/ruby/lib/oso/polar/ffi.rb https://github.com/osohq/oso/blob/1d3bf5a4a997a574c2b19084a0...
- xcskier56 5y agoI figured it was in there somewhere. Thanks for pointing me to the spots! Gonna dig in now and try and grok it (hopefully)
- gkaemmer 5y agoHey, Oso engineer here. Good question. The rust core is indeed called from the ruby library (as it is with all of our 5 other host libraries). The core itself is pretty complex (there's a whole parser/interpreter in there), so maintaining it in a bunch of languages would be a bit hectic. There are some files inside `lib/oso/polar/ffi` that define the C bindings used by the rest of the library. Here's an example: https://github.com/osohq/oso/blob/main/languages/ruby/lib/oso/polar/ffi/query.rb https://github.com/osohq/oso/blob/main/languages/ruby/lib/os... We use the ffi gem to make that work: https://github.com/ffi/ffi https://github.com/ffi/ffi EDIT: hobofan beat me to it! :)
- xcskier56 5y agoThanks for the explanation and the code locations!