Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restruct sentry proj #79

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
14 changes: 14 additions & 0 deletions sentry/activities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from dataclasses import dataclass
from temporalio import activity


@dataclass
class ComposeGreetingInput:
greeting: str
name: str


@activity.defn
async def compose_greeting(input: ComposeGreetingInput) -> str:
activity.logger.info("Running activity with parameter %s" % input)
return f"{input.greeting}, {input.name}!"
26 changes: 1 addition & 25 deletions sentry/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,13 @@
from datetime import timedelta

import sentry_sdk
from temporalio import activity, workflow
from sentry.workflows import compose_greeting, GreetingWorkflow
bkodes marked this conversation as resolved.
Show resolved Hide resolved
from temporalio.client import Client
from temporalio.worker import Worker

from sentry.interceptor import SentryInterceptor


@dataclass
class ComposeGreetingInput:
greeting: str
name: str


@activity.defn
async def compose_greeting(input: ComposeGreetingInput) -> str:
activity.logger.info("Running activity with parameter %s" % input)
return f"{input.greeting}, {input.name}!"


@workflow.defn
class GreetingWorkflow:
@workflow.run
async def run(self, name: str) -> str:
workflow.logger.info("Running workflow with parameter %s" % name)
return await workflow.execute_activity(
compose_greeting,
ComposeGreetingInput("Hello", name),
start_to_close_timeout=timedelta(seconds=10),
)


async def main():
# Uncomment the line below to see logging
# logging.basicConfig(level=logging.INFO)
Expand Down
16 changes: 16 additions & 0 deletions sentry/workflows.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should update the starter.py to reference the workflow from this file and not through the worker.py file

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from temporalio import activity, workflow
from dataclasses import dataclass
from datetime import timedelta
from sentry.activities import ComposeGreetingInput, compose_greeting
bkodes marked this conversation as resolved.
Show resolved Hide resolved


@workflow.defn
class GreetingWorkflow:
@workflow.run
async def run(self, name: str) -> str:
workflow.logger.info("Running workflow with parameter %s" % name)
return await workflow.execute_activity(
compose_greeting,
cretz marked this conversation as resolved.
Show resolved Hide resolved
ComposeGreetingInput("Hello", name),
start_to_close_timeout=timedelta(seconds=10),
)