Git Product home page Git Product logo

hive's Introduction

Hive

Parallel multiple lua states , actor model for lua.

Quick Start

make and run

lua test.lua

the main logic is in test/main.lua .

You can read this blog first (http://blog.codingnow.com/2013/06/hive_lua_actor_model.html) (In Chinese)

How to Launch the hive

local hive = require "hive"

hive.start {
  thread = 4,   -- 4 worker thread, You can set more if you have more cpu core.
	main = "test.main",  -- main cell, the cell name search rule is the same with require.
}

How the cell work

Let's read test/pingpong.lua first.

local cell = require "cell"

cell.command {
  ping = function()
		cell.sleep(1)
		return "pong"
	end
}

function cell.main(...)
	print("pingpong launched")
	return ...
end

If you launch test.pingping, the function cell.main(...) will be execute first.

You can use cell.cmd("launch", "test.pingpong", ...) to launch it.

test.pingpong is a simple cell that support one command 'ping'. If you send a command 'ping' to it, It will sleep 0.01 second first, and the send 'pong' back.

None-blocking socket library

Hive support none-blocking socket api that can be used in every cell.

cell.listen can be used in a server cell, the accepter will be call every time accept a new connection. You can forward the data from new connection to a new cell, or forward to itself (fork a coroutine to deliver the data).

cell.connect can be used in a client cell.

Todo

  • Multi-process support
  • Broadcast message
  • Signal for cell exit
  • Database (Redis/Mongo/SQL) driver
  • Debugger/Monitor
  • Log system (Instead of print error message)
  • Better document
  • Better samples
  • More options in hive.start
  • And more

hive's People

Contributors

cloudwu avatar monadbobo avatar pengyunchou avatar spin6lock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hive's Issues

cell.c not found in cell.lua

~/opensource/hive(branch:master*) % lua52 main.lua
lua52: ./cell.lua:1: module 'cell.c' not found:
no field package.preload['cell.c']
no file '/usr/local/share/lua/5.2/cell/c.lua'
no file '/usr/local/share/lua/5.2/cell/c/init.lua'
no file '/usr/local/lib/lua/5.2/cell/c.lua'
no file '/usr/local/lib/lua/5.2/cell/c/init.lua'
no file './cell/c.lua'
no file '/usr/local/lib/lua/5.2/cell/c.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './cell/c.so'
no file '/usr/local/lib/lua/5.2/cell.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './cell.so'
stack traceback:
[C]: in function 'require'
./cell.lua:1: in main chunk
[C]: in function 'require'
main.lua:1: in main chunk
[C]: in ?

Did you forget to add cell.c file?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.