Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load_setup(self, setup):
for e, s in setup.items():
endpoint = ZmqEndpoint(ZmqEndpointType.bind, e)
ZmqPubConnection.highWaterMark = s['high_water_mark']
connection = ZmqPubConnection(self.factory, endpoint)
for n in s['notification_type_names']:
self.connection_map[n] = connection
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from txzmq import ZmqFactory, ZmqEndpoint, ZmqEndpointType, ZmqPubConnection
import logging
import json
from util import Identity
class ZmqPublisher(ZmqPubConnection):
def __init__(self, zmq_factory, port, data_manager=None):
self.data_manager = data_manager
endpoint = ZmqEndpoint(ZmqEndpointType.bind, "tcp://*:%d" % port)
ZmqPubConnection.__init__(self, zmq_factory, endpoint)
def send_generation_signal(self, generation_number, generation_duration_s):
msg = { "op" : "generation_signal", "identity" : Identity.get_identity(), "generation_number" : generation_number }
if generation_duration_s:
msg["generation_duration_s"] = generation_duration_s
self.publish(json.dumps(msg), "GENSIG")
def load_setup(self, setup):
for e, s in setup.items():
endpoint = ZmqEndpoint(ZmqEndpointType.bind, e)
ZmqPubConnection.highWaterMark = s['high_water_mark']
connection = ZmqPubConnection(self.factory, endpoint)
for n in s['notification_type_names']:
self.connection_map[n] = connection
def main(config):
zmq_requests_factory = ZmqFactory()
zmq_requests_endpoint = ZmqEndpoint(ZmqEndpointType.bind, config['endpoint.command'])
zmq_requests = ZmqRequests(zmq_requests_factory, zmq_requests_endpoint)
zmq_broadcast_factory = ZmqFactory()
zmq_broadcast_endpoint = ZmqEndpoint(ZmqEndpointType.bind, config['endpoint.broadcast'])
zmq_broadcast = ZmqPubConnection(zmq_broadcast_factory, zmq_broadcast_endpoint)
api_endpoint = TCP4ClientEndpoint(reactor, config['ibtws.host'], config['ibtws.port'])
api_endpoint.connect(IBTWSProtocolFactory(zmq_requests, zmq_broadcast))
reactor.run()
def __init__(self, emit_addr, reg_addr):
"""
Initialize the events server.
:param emit_addr: The address in which to receive events from clients.
:type emit_addr: str
:param reg_addr: The address to which publish events to clients.
:type reg_addr: str
"""
TxZmqServerComponent.__init__(self)
# bind PULL and PUB sockets
self._pull, self.pull_port = self._zmq_bind(
txzmq.ZmqPullConnection, emit_addr)
self._pub, self.pub_port = self._zmq_bind(
txzmq.ZmqPubConnection, reg_addr)
# set a handler for arriving messages
self._pull.onPull = self._onPull