Skip to content

Instantly share code, notes, and snippets.

@oahayder
Last active March 23, 2018 17:03
Show Gist options
  • Save oahayder/84ed6e9ec606f1bd602029796af1b7ef to your computer and use it in GitHub Desktop.
Save oahayder/84ed6e9ec606f1bd602029796af1b7ef to your computer and use it in GitHub Desktop.
Require yeild workaround
local resty_dogstatsd = require "resty_dogstatsd"
--BAD. Module level objects
local dogstatsd, err = resty_dogstatsd.new({...})
-- GOOD. Construct connection at runtime
local function get_dogstatsd()
local dogstatsd, err = resty_dogstatsd.new({...})
return dogstatsd
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment