Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Convert to ZDCF 1.0

  • Loading branch information...
commit 1d2857d7836a62a6f33b18d3b6807e951584a19b 1 parent 7c93553
@tsee authored
Showing with 41 additions and 34 deletions.
  1. +41 −34 examples/event_broker/lib/EventBroker.pm
View
75 examples/event_broker/lib/EventBroker.pm
@@ -4,38 +4,45 @@ use Moose;
use ZMQ::Declare;
-my $ClientSpec = ZMQ::Declare::ZDCF->new( tree => {
- client => {
- type => 'event_client',
- event_dispatch => {
- type => 'pub',
- connect => 'tcp://localhost:5999',
- option => {hwm => 10000}
- }
- },
-});
+my $Spec = ZMQ::Declare::ZDCF->new( tree => {
+ version => 1.0,
+ apps => {
+
+ broker => { devices => { broker => {
+ sockets => {
+ event_listener => {
+ type => 'sub',
+ bind => 'tcp://*:5999',
+ option => {subscribe => ''}
+ },
+ work_distributor => {
+ type => 'push',
+ bind => 'tcp://*:5998',
+ option => {hwm => 500000},
+ },
+ }
+ } } },
+
+ worker => { devices => { worker => {
+ sockets => {
+ work_queue => {
+ type => 'pull',
+ connect => 'tcp://localhost:5998',
+ },
+ }
+ } } },
+
+ client => { devices => { client => {
+ sockets => {
+ event_dispatch => {
+ type => 'pub',
+ connect => 'tcp://localhost:5999',
+ option => {hwm => 10000}
+ }
+ }
+ } } },
-my $ServiceSpec = ZMQ::Declare::ZDCF->new( tree => {
- broker => {
- type => 'event_broker',
- event_listener => {
- type => 'sub',
- bind => 'tcp://*:5999',
- option => {subscribe => ''}
- },
- work_distributor => {
- type => 'push',
- bind => 'tcp://*:5998',
- option => {hwm => 500000},
- },
- },
- worker => {
- type => 'event_processor',
- work_queue => {
- type => 'pull',
- connect => 'tcp://localhost:5998',
- },
- },
+ } # end of apps
});
has '_client_runtime' => (
@@ -47,15 +54,15 @@ sub client_socket {
my $self = shift;
my $rt = $self->_client_runtime;
if (not $rt) {
- $rt = $ClientSpec->device("client")->make_runtime;
+ $rt = $Spec->application("client")->device->make_runtime;
$self->_client_runtime($rt);
}
return $rt->get_socket_by_name("event_dispatch");
}
# static and/or instance methods
-sub broker { $ServiceSpec->device("broker") }
-sub worker { $ServiceSpec->device("worker") }
+sub broker { $Spec->application("broker")->device }
+sub worker { $Spec->application("worker")->device }
no Moose;
__PACKAGE__->meta->make_immutable;
Please sign in to comment.
Something went wrong with that request. Please try again.