This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| conf.service:location("/a", [[ | |
| local c = require('foo') | |
| local b, err = c.bar() | |
| if err == nil and type(b) == 'table' then | |
| ngx.say('good') | |
| else | |
| ngx.say(err) | |
| end | |
| ]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| h = vanilla.Hub() | |
| uri = 'ws://localhost:%s' % serve.port | |
| ws = h.http.connect(uri).websocket('/') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local levee = require("levee") | |
| local _ = levee._ | |
| local function main(h) | |
| while true do | |
| local err, n = h.thread:call( | |
| function() | |
| local _ = require("levee._") | |
| local err, no = _.connect("127.0.0.1", 8007) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local d = require("levee").d | |
| local ring = d.HashRing() | |
| ring:put("foo", 3, 2) | |
| print(ring:get("foo")) | |
| ring:del("foo") | |
| ring:put("foo", 3, 2) | |
| print(ring:get("foo") == nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local levee = require("levee") | |
| local _ = levee._ | |
| local h = levee.Hub() | |
| local err, serve = h.tcp:listen(9000) | |
| for conn in serve do | |
| h:spawn(function() | |
| while true do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local levee = require("levee") | |
| local h = levee.Hub() | |
| local connections = 0 | |
| -- HTTP endpoint to see number of connections |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| levee build -e ' | |
| local levee = require("levee") | |
| h = levee.Hub() | |
| local err, serve = h.tcp:listen(8080) | |
| for conn in serve do | |
| local msg = "Hello World" | |
| conn:write("HTTP/1.1 200 OK\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import functools | |
| from decorator import decorator | |
| import pytest | |
| from tornado import ioloop | |
| from tornado import gen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import functools | |
| from decorator import decorator | |
| import pytest | |
| from tornado import ioloop | |
| from tornado import gen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| d.Buffer() | |
| d.Fifo() -- ?? | |
| d.FIFO() | |
| d.Heap() | |
| d.Set() |