Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coolamqp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
coolamqp
Commits
39465a0b
Commit
39465a0b
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
on_fail will be called only if Cluster was connected, v1.0.5
parent
9f327fd4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+5
-0
5 additions, 0 deletions
CHANGELOG.md
coolamqp/__init__.py
+1
-1
1 addition, 1 deletion
coolamqp/__init__.py
coolamqp/attaches/publisher.py
+12
-2
12 additions, 2 deletions
coolamqp/attaches/publisher.py
coolamqp/clustering/cluster.py
+6
-5
6 additions, 5 deletions
coolamqp/clustering/cluster.py
with
24 additions
and
8 deletions
CHANGELOG.md
+
5
−
0
View file @
39465a0b
# v1.0.5:
*
`on_fail`
will be called only if the Cluster has been
connected at least once
# v1.0.4:
# v1.0.4:
*
add missing locals, which rendered CoolAMQP to be unable to process some messages
*
add missing locals, which rendered CoolAMQP to be unable to process some messages
...
...
This diff is collapsed.
Click to expand it.
coolamqp/__init__.py
+
1
−
1
View file @
39465a0b
# coding=UTF-8
# coding=UTF-8
__version__
=
'
1.0.
4
'
__version__
=
'
1.0.
5
'
This diff is collapsed.
Click to expand it.
coolamqp/attaches/publisher.py
+
12
−
2
View file @
39465a0b
...
@@ -80,7 +80,7 @@ class Publisher(Channeler, Synchronized):
...
@@ -80,7 +80,7 @@ class Publisher(Channeler, Synchronized):
class
UnusablePublisher
(
Exception
):
class
UnusablePublisher
(
Exception
):
"""
This publisher will never work (eg. MODE_CNPUB on a broker not supporting publisher confirms)
"""
"""
This publisher will never work (eg. MODE_CNPUB on a broker not supporting publisher confirms)
"""
def
__init__
(
self
,
mode
):
def
__init__
(
self
,
mode
,
cluster_to_set_connected_upon_first_connect
=
None
):
Channeler
.
__init__
(
self
)
Channeler
.
__init__
(
self
)
Synchronized
.
__init__
(
self
)
Synchronized
.
__init__
(
self
)
...
@@ -94,7 +94,7 @@ class Publisher(Channeler, Synchronized):
...
@@ -94,7 +94,7 @@ class Publisher(Channeler, Synchronized):
# Future to confirm or None, flags as tuple|empty tuple
# Future to confirm or None, flags as tuple|empty tuple
self
.
tagger
=
None
# None, or AtomicTagger instance id MODE_CNPUB
self
.
tagger
=
None
# None, or AtomicTagger instance id MODE_CNPUB
self
.
cluster_to_set_connected_upon_first_connect
=
cluster_to_set_connected_upon_first_connect
self
.
critically_failed
=
False
self
.
critically_failed
=
False
self
.
content_flow
=
True
self
.
content_flow
=
True
self
.
blocked
=
False
self
.
blocked
=
False
...
@@ -313,6 +313,16 @@ class Publisher(Channeler, Synchronized):
...
@@ -313,6 +313,16 @@ class Publisher(Channeler, Synchronized):
self
.
state
=
ST_ONLINE
self
.
state
=
ST_ONLINE
self
.
on_operational
(
True
)
self
.
on_operational
(
True
)
# inform the cluster that we've been connected
try
:
self
.
cluster_to_set_connected_upon_first_connect
except
AttributeError
:
pass
else
:
if
self
.
cluster_to_set_connected_upon_first_connect
is
not
None
:
self
.
cluster_to_set_connected_upon_first_connect
.
connected
=
True
del
self
.
cluster_to_set_connected_upon_first_connect
# now we need to listen for BasicAck and BasicNack
# now we need to listen for BasicAck and BasicNack
mw
=
MethodWatch
(
self
.
channel_id
,
(
BasicAck
,
BasicNack
),
mw
=
MethodWatch
(
self
.
channel_id
,
(
BasicAck
,
BasicNack
),
...
...
This diff is collapsed.
Click to expand it.
coolamqp/clustering/cluster.py
+
6
−
5
View file @
39465a0b
...
@@ -71,10 +71,11 @@ class Cluster(object):
...
@@ -71,10 +71,11 @@ class Cluster(object):
self
.
extra_properties
=
extra_properties
self
.
extra_properties
=
extra_properties
self
.
log_frames
=
log_frames
self
.
log_frames
=
log_frames
self
.
on_blocked
=
on_blocked
self
.
on_blocked
=
on_blocked
self
.
connected
=
False
if
on_fail
is
not
None
:
if
on_fail
is
not
None
:
def
decorated
():
def
decorated
():
if
not
self
.
listener
.
terminating
:
if
not
self
.
listener
.
terminating
and
self
.
connected
:
on_fail
()
on_fail
()
self
.
on_fail
=
decorated
self
.
on_fail
=
decorated
...
@@ -221,7 +222,7 @@ class Cluster(object):
...
@@ -221,7 +222,7 @@ class Cluster(object):
self
.
snr
=
SingleNodeReconnector
(
self
.
node
,
self
.
attache_group
,
self
.
snr
=
SingleNodeReconnector
(
self
.
node
,
self
.
attache_group
,
self
.
listener
,
self
.
extra_properties
,
self
.
listener
,
self
.
extra_properties
,
log_frames
,
self
.
name
)
log_frames
,
self
.
name
,
self
)
self
.
snr
.
on_fail
.
add
(
lambda
:
self
.
events
.
put_nowait
(
ConnectionLost
()))
self
.
snr
.
on_fail
.
add
(
lambda
:
self
.
events
.
put_nowait
(
ConnectionLost
()))
if
self
.
on_fail
is
not
None
:
if
self
.
on_fail
is
not
None
:
self
.
snr
.
on_fail
.
add
(
self
.
on_fail
)
self
.
snr
.
on_fail
.
add
(
self
.
on_fail
)
...
@@ -230,7 +231,7 @@ class Cluster(object):
...
@@ -230,7 +231,7 @@ class Cluster(object):
self
.
snr
.
on_blocked
.
add
(
self
.
on_blocked
)
self
.
snr
.
on_blocked
.
add
(
self
.
on_blocked
)
# Spawn a transactional publisher and a noack publisher
# Spawn a transactional publisher and a noack publisher
self
.
pub_tr
=
Publisher
(
Publisher
.
MODE_CNPUB
)
self
.
pub_tr
=
Publisher
(
Publisher
.
MODE_CNPUB
,
cluster_to_set_connected_upon_first_connect
=
self
)
self
.
pub_na
=
Publisher
(
Publisher
.
MODE_NOACK
)
self
.
pub_na
=
Publisher
(
Publisher
.
MODE_NOACK
)
self
.
decl
=
Declarer
()
self
.
decl
=
Declarer
()
...
@@ -245,9 +246,9 @@ class Cluster(object):
...
@@ -245,9 +246,9 @@ class Cluster(object):
if
wait
:
if
wait
:
# this is only going to take a short amount of time, so we're fine with polling
# this is only going to take a short amount of time, so we're fine with polling
start_at
=
monotonic
.
monotonic
()
start_at
=
monotonic
.
monotonic
()
while
not
self
.
attache_group
.
is_online
()
and
monotonic
.
monotonic
()
-
start_at
<
timeout
:
while
not
self
.
connected
and
monotonic
.
monotonic
()
-
start_at
<
timeout
:
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
if
not
self
.
attache_group
.
is_online
()
:
if
not
self
.
connected
:
raise
ConnectionDead
(
raise
ConnectionDead
(
'
[%s] Could not connect within %s seconds
'
%
(
self
.
name
,
timeout
,))
'
[%s] Could not connect within %s seconds
'
%
(
self
.
name
,
timeout
,))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment