Skip to content

Endpoint to edit existing rules #499

@bracyw

Description

@bracyw

Description

Edit rule expression/debounce for all subscribers (affects everyone subscribed to this rule). Used when a rule's logic needs to be updated system-wide without requiring all clients to delete and recreate their subscriptions, maintaining subscription continuity while updating rule behavior. Topic cannot be changed - clients must create a new rule if they need a different topic.

Related diagram:

sequenceDiagram
    participant User
    participant Client
    participant Server
    
    User->>Client: Click edit button
    
    Note over Client,User: (a) Edit Options
    alt Edit rule for everyone
        Client->>User: Open popup to edit rule (topic disabled)
        User->>User: Make changes
        User->>Client: Click save
    else Create new rule based on old
        Client->>User: Open popup with pre-filled config
        User->>User: Make changes
        User->>Client: Click save
    end
    
    Note over Client,Server: (b) Process Edit
    alt Edit for everyone
        Client->>Server: PUT /rules/edit/{rule_id}
        Note right of Server: (c1) Server Logic: Get rule from hashmap, Update rule fields in place
        Server->>Server: Update rule
    else Create new rule
        Client->>Server: POST /rules/add
        Note right of Server: (c2) Server Logic: Insert into BiMap, Update topic_index, Insert into rules hashmap
        Server->>Server: Add new rule
    end
    Server-->>Client: Success response
    
    Note over Client,User: (d) UI Update
    Client->>User: Popup closes and rule list updates
Loading

Acceptance Criteria

  • Topic cannot be changed
  • Updates rule for all subscribers
  • Returns error if rule_id not found

Proposed Solution

PUT /rules/edit/{rule_id}
Body: { expr: String, debounce_time: Duration }
Response: 200 OK

Add edit_rule() method to RuleManager in rule_structs.rs, add endpoint to rule_controller.rs. Reference add_rule() for write lock pattern on rules hashmap. Test using Postman for basic functionality, then add tests to rule_structs_test.rs.

Mocks

No response

Metadata

Metadata

Assignees

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