Skip to content

implementation of the kyototycoon slave protocol for ngx-lua

Notifications You must be signed in to change notification settings

webcore-no/lua-resty-kyototycoon-slave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 

Repository files navigation

Name

lua-resty-kyototycoon-slave

Table of Contents

Status

This library is already usable though still highly experimental.

The Lua API is still in flux and may change in the near future without notice.

Back to TOC

Synopsis

http {
	init_worker_by_lua_block {

		if ngx.worker.id() == 0 then
			local slave_id = 1
			local master_ip = '127.0.0.1'
			local master_port = 1978

			local kt = require "resty.kyototycoon.slave"
			local cjson = require "cjson.safe"

			local slave, err = kt.new(slave_id, master_ip, master_port)

			if not slave then
				ngx.log(ngx.ERR, "failed to create kyoto slave instance:", err)
				return ngx.exit()
			end

			local slave_cb = function(cmd, err)
				if not cmd then
					return ngx.log(ngx.ERR, err)
				end

				ngx.log(ngx.ERR, cjson.encode(cmd))
			end

			local ok, err = ngx.timer.at(0, slave.replicate, slave, slave_cb, ngx.now() * 1000000000)

			if not ok then
				ngx.log(ngx.ERR, "failed to start create timer: ", err)
				return ngx.exit()
			end
		end
	}
}

Back to TOC

Description

This library provides a implementation of the kyototycoon slave protocol

Back to TOC

Installation

Copy the contents of the lib directory to a path in ngx-lua's search path

Load the module provided by this library in Lua. For example,

local kt_slave = require "resty.kyototycoon.slave".new(id, ip, port)

local ok, err = kt_slave:replicate(callback_function, from_ts)

Back to TOC

Bugs and Patches

Please report bugs or submit patches by

Creating a ticket on the GitHub Issue Tracker,

Back to TOC

Author

Bjørnar Ness bjornar.ness@gmail.com

Back to TOC

Copyright and License

This module is licensed under the BSD license.

Copyright (C) 2016-2017, by Bjørnar Ness

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Back to TOC

See Also

Back to TOC

About

implementation of the kyototycoon slave protocol for ngx-lua

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages