A super-lightweight Lua microservice (toy) framework.

Overview

Hive

A super-lightweight microservice (toy) framework written in Rust. It uses Lua as interface to provide simple, fun developing experience and fast deployment. It is currently under heavy development, and many functionalities are yet to be implemented.

Get Started

Service file:

hive.name = "hello"

local function hello(req)
  local name = req.params.name or "world"
  return { greeting = "Hello, " .. name .. "!" }
end

register("/", hello)
register("/:name", hello)

Run server:

$ cargo run --release
INFO hive > Access key: *your-access-key*
INFO hive > Server is running at http://127.0.0.1:3000

Upload service:

$ curl 127.0.0.1:3000/upload -F "code=@/path/to/service/file.lua" -H "Hive-Access-Key: *your-access-key*"

Get greetings:

# '%' indicates that there is no line break at the end of the body. It is not
# present in actual body.
$ curl 127.0.0.1:3000/hello
{"greeting":"Hello, world!"}%

$ curl 127.0.0.1:3000/hello/Eric
{"greeting":"Hello, Eric!"}%

Lua version compatibility

Hive uses LuaJIT as default, and is compatible with Lua 5.4, 5.3, 5.2 and 5.1.

You can build Hive with other versions of Lua using the following command:

$ cargo build --no-default-features --features lua{jit|54|53|52|51}

License

Hive is licensed under the MIT License.

You might also like...
Rust scaffold system with Lua embedded applets.
Rust scaffold system with Lua embedded applets.

brickpack-2022 Demo Powered by Github Actions CI/CD (Heroku) https://demo-1642622230.herokuapp.com/#/users Frontent Runner Rendered sample code (Lua 5

This tool converts Lua code to TS automatically, including the conversion of common standards to their TS equivalents.

lua-to-ts This tool converts Lua code to TS automatically, including the conversion of common standards to their TS equivalents. Code that fails to be

Another cursed Garry's Mod module. This time, it adds the C preprocessor to Lua scripts

gm_cpreprocessor Another cursed Garry's Mod module. This time, it adds the C preprocessor to Lua scripts. It works by detouring RunStringEx and overri

Node.js bindings to Lua

Node.js bindings to Lua

 ⚡ Fast Web Security Scanner written in Rust based on Lua Scripts 🌖 🦀
⚡ Fast Web Security Scanner written in Rust based on Lua Scripts 🌖 🦀

⚡ Fast Web Security Scanner written in Rust based on Lua Scripts 🌖 🦀

swc is a super-fast compiler written in rust; producing widely-supported javascript from modern standards and typescript.
swc is a super-fast compiler written in rust; producing widely-supported javascript from modern standards and typescript.

Make the web (development) faster. SWC (stands for Speedy Web Compiler) is a super-fast TypeScript / JavaScript compiler written in Rust. It's a libra

Sol is a lightweight language primarily designed for scripting environments

☀️ Sol A dynamically-typed (for now) and procedural programming language. About Sol is a lightweight language primarily designed for scripting environ

A lightweight sandbox sim written in Rust.
A lightweight sandbox sim written in Rust.

Rusty Sandbox A lightweight sandbox sim written in Rust. Play via Browser (WASM) | Compile by yourself This is a quick hobby project written to practi

Minimal framework to inject the .NET Runtime into a process in Rust

錆の核 sabinokaku Minimal framework to inject the .NET Runtime into a process. Supports Windows and Linux. macOS support is complicated due to SIP, and w

Comments
  • Server returns error when uploading lua scripts

    Server returns error when uploading lua scripts

    Env Info

    • Operating System: Arch Linux x86_64 with 5.17.1-zen1-1-zen
    • rustc Version: 1.59.0
    • hive Version: master branch, commit ba132f1

    Error

    To reproduce, upload a lua script via curl:

    curl localhost:3000/services/hello -X PUT -F [email protected] | jq
    

    Server returns:

    {
      "error": "I/O error",
      "detail": {
        "msg": "Invalid cross-device link (os error 18)"
      }
    }
    

    And the log of server shows:

     ERROR hive_server::handle > Invalid cross-device link (os error 18)
    
    opened by YukariChiba 2
  • Stream API

    Stream API

    Provides three interfaces: Stream, Sink and Transform. These enable cryptography, compression and many other use cases.

    local stream = {
      read = function(self)
        return "some bytes"
      end
    }
    
    local sink = {
      write = function(self, bytes)
        -- write `bytes` to some place
        return how_many_bytes_read
      end
    }
    
    local transform = {
      transform = function(self, bytes)
        return "some transformed bytes"
      end
    }
    
    • [x] Replace current concrete type Stream with abstract interface and concrete implementations
      • Define implementation rules
    • [x] Allow using stream as body
      • Rust side: use Body::channel, return the body, and then spawn a new task to drain the stream
    • [x] Helper functions
      • Pipe stream into sink, wrap stream or sink with transform, etc.
    enhancement 
    opened by hack3ric 1
  • Hot update

    Hot update

    Current service updating model requires removing original service first, which is not ideal when error occurs and the original service cannot be recovered.

    This problem may be solved by attempting to create service first and then replace the original one.

    enhancement 
    opened by hack3ric 0
  • Remote `require`

    Remote `require`

    Allows requireing modules over HTTP.

    local baaz = require "foo.bar.baaz @https://getabel.org/x/mymodule/0.1.0"
    local mymodule = require "@https://getabel.org/x/mymodule/0.1.0"
    
    • [x] Implement MVP
      • You can use it right now, but not guaranteed to work as you would expect
    • [ ] Caching
    • [ ] Repository
      • Basically a file server, but need to specify the file structure
    • [ ] URI alias
      • Specify in service's config file?
    enhancement 
    opened by hack3ric 0
Owner
Eric Long
Eric Long
Lua 5.3 bindings for Rust

rust-lua53 Aims to be complete Rust bindings for Lua 5.3 and beyond. Currently, master is tracking Lua 5.3.3. Requires a Unix-like environment. On Win

J.C. Moyer 150 Dec 14, 2022
Safe Rust bindings to Lua 5.1

rust-lua Copyright 2014 Lily Ballard Description This is a set of Rust bindings to Lua 5.1. The goal is to provide a (relatively) safe interface to Lu

Lily Ballard 124 Jan 5, 2023
Zero-cost high-level lua 5.3 wrapper for Rust

td_rlua This library is a high-level binding for Lua 5.3. You don't have access to the Lua stack, all you can do is read/write variables (including ca

null 47 May 4, 2022
Rust library to interface with Lua

hlua This library is a high-level binding for Lua 5.2. You don't have access to the Lua stack, all you can do is read/write variables (including callb

Pierre Krieger 488 Dec 26, 2022
Pure Rust Lua implementation

purua Pure Rust Lua implementation Usage $ bat lua_examples/defun.lua ───────┬────────────────────────────────────────── │ File: lua_examples/d

Kondo Uchio 35 Dec 28, 2021
📦 Pack hundreds of Garry's Mod Lua files into just a handful

?? gluapack gluapack is a program that can pack hundreds of Garry's Mod Lua files into just a handful. Features Quick, easy and portable - perfect for

null 11 Aug 10, 2021
A memory safe Lua interpreter

Hematita Da Lua Hematita Da Lua is an interpreter for the scripting language Lua, written entirely in 100% safe Rust. Hematita is the portugese word f

Daniel 149 Dec 29, 2022
A script language like Python or Lua written in Rust, with exactly the same syntax as Go's.

A script language like Python or Lua written in Rust, with exactly the same syntax as Go's.

null 1.4k Jan 1, 2023
🐱‍👤 Cross-language static library for accessing the Lua state in Garry's Mod server plugins

gmserverplugin This is a utility library for making Server Plugins that access the Lua state in Garry's Mod. Currently, accessing the Lua state from a

William 5 Feb 7, 2022
A parser, compiler, and virtual machine evaluator for a minimal subset of Lua; written from scratch in Rust.

lust: Lua in Rust This project implements a parser, compiler, and virtual machine evaluator for a minimal subset of Lua. It is written from scratch in

Phil Eaton 146 Dec 16, 2022