Test Setup Failed
Pull Request — master (#4154)
by W
03:25
created

WorkflowExecution._get_publisher()   A

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 7
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 __future__ import absolute_import
17
18
from st2common import transport
19
from st2common.models import db
20
from st2common.models.db import workflow as wf_db_models
21
from st2common.persistence import base as persistence
22
from st2common.transport import utils as transport_utils
23
24
25
__all__ = [
26
    'WorkflowExecution',
27
    'TaskExecution'
28
]
29
30
31
class WorkflowExecution(persistence.StatusBasedResource):
32
    impl = db.ChangeRevisionMongoDBAccess(wf_db_models.WorkflowExecutionDB)
33
    publisher = None
34
35
    @classmethod
36
    def _get_impl(cls):
37
        return cls.impl
38
39
    @classmethod
40
    def _get_publisher(cls):
41
        if not cls.publisher:
42
            cls.publisher = transport.workflow.WorkflowExecutionPublisher(
43
                urls=transport_utils.get_messaging_urls())
44
45
        return cls.publisher
46
47
48
class TaskExecution(persistence.StatusBasedResource):
49
    impl = db.ChangeRevisionMongoDBAccess(wf_db_models.TaskExecutionDB)
50
    publisher = None
51
52
    @classmethod
53
    def _get_impl(cls):
54
        return cls.impl
55