You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check if a rule with a given topic and expression already exists (in service of editing rules, or creating new ones, to avoid creating duplicate rules and for convenience if the client ever wants to check if a rule exists still server side)
Related diagram:
sequenceDiagram
participant User
participant Client
participant Server
User->>Client: Click Add button
Note over Client,Server: (a) Check for Existing Rule
Client->>Server: POST /rules/check (topic, expr)
Note right of Server: Check if rule exists in rules hashmap
Server-->>Client: Return rule_id or null
Note over Client: (b) User Confirmation Flow
alt Matching rule exists
Client->>User: Ask: Sure you want to make rule again?
User->>Client: Confirm
else No matching rule
Note over Client: Continue to add
end
Note over Client,Server: (c) Add Rule
Client->>Server: POST /rules/add (Rule, client_id)
Note right of Server: (d) Server Logic: Insert (client, rule_id) into BiMap, Add rule_id to topic_index, Insert rule into rules hashmap
Server->>Server: Add rule
Server-->>Client: Success response
Note over Client,User: (e) UI Update
Client->>User: Update rule list display
Add check_rule() method to RuleManager in rule_structs.rs, add endpoint to rule_controller.rs. Reference get_all_rules() for hashmap read pattern. Test using Postman for basic functionality, then add tests to rule_structs_test.rs.
Description
Check if a rule with a given topic and expression already exists (in service of editing rules, or creating new ones, to avoid creating duplicate rules and for convenience if the client ever wants to check if a rule exists still server side)
Related diagram:
sequenceDiagram participant User participant Client participant Server User->>Client: Click Add button Note over Client,Server: (a) Check for Existing Rule Client->>Server: POST /rules/check (topic, expr) Note right of Server: Check if rule exists in rules hashmap Server-->>Client: Return rule_id or null Note over Client: (b) User Confirmation Flow alt Matching rule exists Client->>User: Ask: Sure you want to make rule again? User->>Client: Confirm else No matching rule Note over Client: Continue to add end Note over Client,Server: (c) Add Rule Client->>Server: POST /rules/add (Rule, client_id) Note right of Server: (d) Server Logic: Insert (client, rule_id) into BiMap, Add rule_id to topic_index, Insert rule into rules hashmap Server->>Server: Add rule Server-->>Client: Success response Note over Client,User: (e) UI Update Client->>User: Update rule list displayAcceptance Criteria
Proposed Solution
Add
check_rule()method to RuleManager inrule_structs.rs, add endpoint torule_controller.rs. Referenceget_all_rules()for hashmap read pattern. Test using Postman for basic functionality, then add tests torule_structs_test.rs.Mocks
No response