Skip to content

Commit

Permalink
support tcp keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
smallfish committed Oct 31, 2012
1 parent 47dfa69 commit 5283226
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Expand Up @@ -78,8 +78,13 @@ Synopsis
end
end

-- close
bean:close()
-- put it into the connection pool of size 100,
-- with 0 idle timeout

bean:set_keepalive(0, 100)

-- close and quit beanstalkd
-- bean:close()
';
}
}
Expand Down
8 changes: 8 additions & 0 deletions lib/resty/beanstalkd.lua
Expand Up @@ -29,6 +29,14 @@ function set_timeout(self, timeout)
return sock:settimeout(timeout)
end

function set_keepalive(self, ...)
local sock = self.sock
if not sock then
return nil, "not initialized"
end
return sock:setkeepalive(...)
end

function connect(self, host, port, ...)
local sock = self.sock
if not sock then
Expand Down

0 comments on commit 5283226

Please sign in to comment.