Skip to content

Commit

Permalink
connect will create a socket if one isn't there fixes #44
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Oct 15, 2021
1 parent 99bf012 commit f3e5db7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pgmoon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ do
return self:set_type_oid(tonumber(res.oid), "hstore")
end,
connect = function(self)
if not (self.sock) then
self.sock = socket.new(self.sock_type)
end
local opts
if self.sock_type == "nginx" then
opts = {
Expand Down
3 changes: 3 additions & 0 deletions pgmoon/init.moon
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ class Postgres
@application_name = opts.application_name or "pgmoon"

connect: =>
unless @sock
@sock = socket.new @sock_type

opts = if @sock_type == "nginx"
{
pool: @pool_name or "#{@host}:#{@port}:#{@database}:#{@user}"
Expand Down

0 comments on commit f3e5db7

Please sign in to comment.