Passed
Push — master ( f1fe9e...5c5de8 )
by
unknown
03:44
created

ActionExecutionOutput._get_publisher()   A

Complexity

Conditions 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
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
from st2common import transport
17
from st2common.models.db import MongoDBAccess
18
from st2common.models.db.execution import ActionExecutionDB
19
from st2common.models.db.execution import ActionExecutionOutputDB
20
from st2common.persistence.base import Access
21
from st2common.transport import utils as transport_utils
22
23
__all__ = [
24
    'ActionExecution',
25
    'ActionExecutionOutput',
26
]
27
28
29
class ActionExecution(Access):
30
    impl = MongoDBAccess(ActionExecutionDB)
31
    publisher = None
32
33
    @classmethod
34
    def _get_impl(cls):
35
        return cls.impl
36
37
    @classmethod
38
    def _get_publisher(cls):
39
        if not cls.publisher:
40
            cls.publisher = transport.execution.ActionExecutionPublisher(
41
                urls=transport_utils.get_messaging_urls())
42
        return cls.publisher
43
44
    @classmethod
45
    def delete_by_query(cls, **query):
46
        return cls._get_impl().delete_by_query(**query)
47
48
49
class ActionExecutionOutput(Access):
50
    impl = MongoDBAccess(ActionExecutionOutputDB)
51
52
    @classmethod
53
    def _get_impl(cls):
54
        return cls.impl
55
56
    @classmethod
57
    def _get_publisher(cls):
58
        if not cls.publisher:
59
            cls.publisher = transport.execution.ActionExecutionOutputPublisher(
60
                urls=transport_utils.get_messaging_urls())
61
        return cls.publisher
62
63
    @classmethod
64
    def delete_by_query(cls, **query):
65
        return cls._get_impl().delete_by_query(**query)
66