Skip to content

Endpoint for batch rule subscription #497

@bracyw

Description

@bracyw

Description

Subscribe client to multiple existing rules in a single request (used when users select multiple rules from the UI via checkboxes or bulk actions, enabling efficient subscription management without individual API calls per rule, improving UX and reducing network overhead)

Related diagram:

sequenceDiagram
    participant User
    participant Client
    participant Server
    
    User->>Client: Click Subscribe (checkbox or button)
    
    Note over Client,Server: (a) Subscribe to Rule(s)
    Client->>Server: POST /rules/subscribe (rule_ids, client_id)
    Note right of Server: (b) Server Logic: For each rule_id, insert (client_id, rule_id) into BiMap
    Server->>Server: Subscribe to rules
    Server-->>Client: Success response
    
    Note over Client,User: (c) UI Update
    Client->>User: Update rule list display
Loading

Acceptance Criteria

  • Accepts list of rule_ids
  • Adds client to subscriptions for each rule
  • Time: O(n) where n = rules to subscribe

Proposed Solution

POST /rules/subscribe
Body: { rule_ids: Vec<RuleId>, client_id: ClientId }
Response: 200 OK

Add subscribe_rules() method to RuleManager in rule_structs.rs, add endpoint to rule_controller.rs. Reference add_rule() for BiMap insert pattern: subscriptions.write().await.insert(&client, &rule_id). Test using Postman for basic functionality, then add tests to rule_structs_test.rs.

Mocks

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    mediumA more complex taskscylla-serverDevelopment Focused in the Backend

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions