-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96fc418
commit 4ab9d0e
Showing
2 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
32 changes: 29 additions & 3 deletions
32
src/examples/issue_classification_user_journey/issue_dispatcher/issue_dispatcher.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
from abc import ABC | ||
|
||
class Issue(): | ||
def __init__(self, id: str, title: str): | ||
self.id = id | ||
self.title = title | ||
|
||
class IssuePort(ABC): | ||
pass | ||
def get_next(self) -> Issue: | ||
pass | ||
def dispatch_to(self, recipient: str, issue_id: str) -> None: | ||
pass | ||
|
||
|
||
class IssueDispatcher(): | ||
def __init__(self, issue_port: IssuePort): | ||
|
||
class ClassifierPort(ABC): | ||
def classify(self, issue: Issue)->str: | ||
pass | ||
|
||
|
||
class IssueDispatcher(): | ||
def __init__(self, issues: IssuePort, classifier: ClassifierPort): | ||
self.issues = issues | ||
self.classifier = classifier | ||
|
||
def dispatch_next_issue(self): | ||
issue = self.issues.get_next() | ||
recipient = self.classifier.classify(issue) | ||
self.issues.dispatch_to(recipient, issue.id) | ||
|
||
def run(self): | ||
while True: | ||
self.dispatch_next_issue() | ||
|
||
|
||
|
29 changes: 24 additions & 5 deletions
29
src/examples/issue_classification_user_journey/test/test_issue_dispatching.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters