Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Added
to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724 #5726 #5725 #5732 #5733 #5737 #5738
Contributed by @cognifloyd

* Added publischer to ActionAlias
Contributed @ubaumann

Changed
~~~~~~~

Expand Down
15 changes: 13 additions & 2 deletions st2common/st2common/persistence/actionalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,24 @@
# limitations under the License.

from __future__ import absolute_import
from st2common import transport
from st2common.models.db.actionalias import actionalias_access
from st2common.persistence import base as persistence
from st2common.persistence.base import Access

__all__ = [
"ActionAlias",
]

class ActionAlias(persistence.Access):

class ActionAlias(Access):
impl = actionalias_access

@classmethod
def _get_impl(cls):
return cls.impl

@classmethod
def _get_publisher(cls):
if not cls.publisher:
cls.publisher = transport.actionalias.ActionAliasPublisher()
return cls.publisher
42 changes: 42 additions & 0 deletions st2common/st2common/transport/actionalias.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2020 The StackStorm Authors.
# Copyright 2019 Extreme Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# All Exchanges and Queues related to liveaction.

from __future__ import absolute_import
from kombu import Exchange, Queue
from st2common.transport import publishers

__all__ = [
"ActionAliasPublisher",
"get_queue",
]

ACTIONALIAS_XCHG = Exchange("st2.actionalias", type="topic")


class ActionAliasPublisher(publishers.CUDPublisher):
def __init__(self):
super(ActionAliasPublisher, self).__init__(exchange=ACTIONALIAS_XCHG)


def get_queue(name=None, routing_key=None, exclusive=False, auto_delete=False):
return Queue(
name,
ACTIONALIAS_XCHG,
routing_key=routing_key,
exclusive=exclusive,
auto_delete=auto_delete,
)
2 changes: 2 additions & 0 deletions st2common/st2common/transport/bootstrap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from st2common import log as logging
from st2common.transport import utils as transport_utils
from st2common.transport.actionalias import ACTIONALIAS_XCHG
from st2common.transport.actionexecutionstate import ACTIONEXECUTIONSTATE_XCHG
from st2common.transport.announcement import ANNOUNCEMENT_XCHG
from st2common.transport.connection_retry_wrapper import ConnectionRetryWrapper
Expand Down Expand Up @@ -62,6 +63,7 @@

# List of exchanges which are pre-declared on service set up.
EXCHANGES = [
ACTIONALIAS_XCHG,
ACTIONEXECUTIONSTATE_XCHG,
ANNOUNCEMENT_XCHG,
EXECUTION_XCHG,
Expand Down