connectFree/lev

[process][lev] object API

kristate opened this issue · 10 comments

There has been some confustion between the global lev object and the global process object

Using Node.JS/libuv as a base, here is how we will split the two:

lev object: handles function of entire lev operations (multicore, et cetera)

lev→lev.abort()
lev→lev.exit([code])
lev→lev.getgid()
lev→lev.setgid(id)
lev→lev.getuid()
lev→lev.setuid(id)
lev→lev.kill(pid, [signal])
lev→lev.umask([mask])
lev→lev.uptime()
lev→lev.hrtime()

process object: handles per core operations

process→Event: 'exit'
process→Event: 'uncaughtException'
process→Signal Events
process→process.stdout
process→process.stderr
process→process.stdin
process→process.argv
process→process.execPath
process→process.chdir(directory)
process→process.cwd()
process→process.env
process→process.version
process→process.versions
process→process.config
process→process.pid
process→process.title
process→process.arch
process→process.platform
process→process.memoryUsage()
process→process.nextTick(callback)

Process should only be a global object defined from kickstart.lua

I see that we have a process C module -- this functionality should be moved to lev_new_core.c
https://github.com/connectFree/lev/blob/master/src/lev_new_process.c

Any process functionality required in C should be implemented in lev_new_core.c and extended to the process object via kickstart.lua
https://github.com/connectFree/lev/blob/master/lib/lev/kickstart.lua

I think the following should have as API of the global lev object.
Because, these fixed at start up.

  • process.version => lev.version
  • process.versions => lev.versions
  • process.arch => lev.arch
  • process.platform => lev.platform

@kazupon agreed -- let's move process.arch and process.platform to the lev object.

I am proposing process.getenv(name) and process.setenv(name, value) instead of process.env.
It is simpler this way.

@hnakamur
Thanks for pull-request.

I am proposing process.getenv(name) and process.setenv(name, value) instead of process.env.
It is simpler this way.

I agree.
Function is lighter than the table.

I think implementation of "lenv.c" needs to be integrated into the "process"

@kristate
How about you?

Ah, I didn't notice "lenv.c".
We need to iterate or get all environment variables as well as getenv().
I think it is better to implement process.environ() as an iterator with technics written in
http://www.lua.org/pil/29.1.html

As a related issue, see #65

Let me clarify my understanding.

  • process→process.stdout == _G.process.stdout
  • process→process.stderr == _G.process.stderr
  • process→process.stdin == _G.process.stdin
  • process→process.argv == _G.arg

Is it acceptable for you?

Or, stdout, stdin, stderr are the same as Node, stream-based object?
http://nodejs.org/api/stream.html

I think we need to check whether the Non-blocking _G.process.stdout, _G.process.stdin, the _G.process.stderr.
Maybe, I think blocking.

@hnakamur

Pull Request #64: Add getenv(), setenv() and unsetenv() in process.

Thanks for the commit.
I cherry-pick this commit you.

kazupon@ce28707

Pull Request #70: Process environ

Thanks!!
We are very pleased to cherry-pick your this pull-request.

Resolved in commit b52f4ab -> closing