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

Mapping of "action" string to next function #1931

Closed
11 tasks
Tracked by #1922
humansinstitute opened this issue Nov 11, 2024 · 4 comments
Closed
11 tasks
Tracked by #1922

Mapping of "action" string to next function #1931

humansinstitute opened this issue Nov 11, 2024 · 4 comments
Assignees

Comments

@humansinstitute
Copy link
Contributor

humansinstitute commented Nov 11, 2024

Context

After receiving responses from Stakwork workflows, the system needs to execute different actions based on the workflow type and response. We need a flexible, maintainable system to map workflow responses to their corresponding handler functions.

Design

@tobi-bams can you map out a design for this.

e.g:

Action Registry - defines all actions strings that map to default to "log and exit"
Action Context - typed objects for
Action Handlers - e.g. update user stories, output ticket plan, log and exit

e.g. context

type ActionContext struct {
    RequestUUID  string    // A unique ID for this request
    WorkflowID   string    // Which workflow it came from
    Source       string    // Where it came from
    ActionString string    // What needs to be done
    ResponseData []byte    // The actual data to process
}

Assignment Criteria

  • Strong understanding of Go interfaces and dependency injection
  • Experience with concurrent operations in Go
  • Connected on Sphinx V2

Acceptance Criteria

  • Implement ActionHandler interface
  • Create ActionRegistry with thread-safe operations
  • Implement example handlers for:
    • User story generation
    • Ticket planning
    • (Other workflow types as needed)
  • Add comprehensive unit tests for registry and handlers
  • Add integration tests for the complete workflow
  • Implement error handling and logging
  • Document handler registration process
  • Create examples for adding new handlers

Usage Example

To add a new workflow action:

  1. Define a new handler:
type NewFeatureHandler struct {
    db     *sqlx.DB
    logger *zap.Logger
}

func (h *NewFeatureHandler) Handle(ctx context.Context, actionCtx ActionContext) error {
    // Implementation
    return nil
}

func (h *NewFeatureHandler) ValidateInput(actionCtx ActionContext) error {
    // Validation
    return nil
}
  1. Register the handler:
registry.Register("new_feature_workflow", &NewFeatureHandler{db: db, logger: logger})
  1. Use in workflow:
// In your workflow response
{
    "action_string": "new_feature_workflow",
    "request_uuid": "...",
    "response_data": {...}
}
@Shoaibdev7
Copy link
Contributor

Shoaibdev7 commented Nov 11, 2024

@humansinstitute.Please assign me?

@sophieturner0
Copy link

sophieturner0 commented Nov 11, 2024

@humansinstitute Could you please assign me?

1 similar comment
@MahtabBukhari
Copy link
Contributor

@humansinstitute Could you please assign me?

@humansinstitute
Copy link
Contributor Author

Now defunct with #1926 & #1927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants