Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to reuse/set ZMQ context used by Mongrel2 #5

Closed
wants to merge 1 commit into from

Conversation

paneq
Copy link
Collaborator

@paneq paneq commented Jul 12, 2012

As stated in: http://zguide.zeromq.org/page:all#Getting-the-Context-Right : "You should create and use exactly one context in your process"

Sometimes the programmer might want to create the Context itself and let
the handler use it. It can be done in two ways:

a) setting Mongrel2.zmq_context
b) providing it as a dependency when creating new Connection:

Mongrel2::Connection.new(sender_id, pull_addr, pub_addr, context)

But most people do not have such needs so by default we create our own
context with 1 thread for IO.

As stated in:
http://zguide.zeromq.org/page:all#Getting-the-Context-Right
"You should create and use exactly one context in your process"

Sometimes the programmer might want to create the Context itself and let
the handler use it. It can be done in two ways:

a) setting `Mongrel2.zmq_context`
b) providing it as a dependency when creating new Connection:

     Mongrel2::Connection.new(sender_id, pull_addr, pub_addr, context)

But most people do not have such needs so by default we create our own
context with 1 thread for IO.
@paneq
Copy link
Collaborator Author

paneq commented Jul 12, 2012

I also try to establish in this commit a basic culture of testing :) What do you think @perplexes , @pawelpacana ?

@mostlyobvious
Copy link
Collaborator

I totally support this since it:

  • removes global CTX
  • doesn't change default behaviour
  • lazy loades context (which may be loaded lately i.e. after fork and won't cause trouble for those who need that behaviour)
  • I can provide my own context when I need it

@mostlyobvious
Copy link
Collaborator

@paneq Can you please rebase on master?

@paneq
Copy link
Collaborator Author

paneq commented Jul 13, 2012

yep.

@paneq paneq mentioned this pull request Jul 13, 2012
@paneq
Copy link
Collaborator Author

paneq commented Jul 13, 2012

Closing in favor of #12

@paneq paneq closed this Jul 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants