Passed
Push — develop ( f1fe9e...5c5de8 )
by
unknown
06:59 queued 03:36
created

ActionExecutionOutputPublisher.__init__()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
dl 0
loc 2
rs 10
1
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
16
# All Exchanges and Queues related to liveaction.
17
18
from kombu import Exchange, Queue
19
from st2common.transport import publishers
20
21
__all__ = [
22
    'ActionExecutionPublisher',
23
    'ActionExecutionOutputPublisher',
24
25
    'get_queue',
26
    'get_output_queue'
27
]
28
29
EXECUTION_XCHG = Exchange('st2.execution', type='topic')
30
EXECUTION_OUTPUT_XCHG = Exchange('st2.execution.output', type='topic')
31
32
33
class ActionExecutionPublisher(publishers.CUDPublisher):
34
    def __init__(self, urls):
35
        super(ActionExecutionPublisher, self).__init__(urls, EXECUTION_XCHG)
36
37
38
class ActionExecutionOutputPublisher(publishers.CUDPublisher):
39
    def __init__(self, urls):
40
        super(ActionExecutionOutputPublisher, self).__init__(urls, EXECUTION_OUTPUT_XCHG)
41
42
43
def get_queue(name=None, routing_key=None, exclusive=False):
44
    return Queue(name, EXECUTION_XCHG, routing_key=routing_key, exclusive=exclusive)
45
46
47
def get_output_queue(name=None, routing_key=None, exclusive=False):
48
    return Queue(name, EXECUTION_OUTPUT_XCHG, routing_key=routing_key, exclusive=exclusive)
49