sequencia-inscricao.puml (1850B)
1 @startuml sequencia-inscricao 2 title SIGA - Sequência: inscrever em evento (POST /signup) 3 4 autonumber 5 actor Participante as P 6 participant "handlers\n(signups)" as H 7 participant "auth\n(Go)" as AuthSvc 8 participant "event_registration\n(Zig)" as Ev 9 participant "repository\n(signups)" as Repo 10 database "signups\n(db.db)" as SDb 11 12 P -> H : POST /signup\nAuthorization: Bearer <token>\n{"event_id": 1} 13 activate H 14 15 H -> H : authenticate(w, r)\nbearer(r) 16 alt token ausente 17 H --> P : 401 missing bearer token 18 else token presente 19 H -> AuthSvc : GET /{token} 20 alt auth fora do ar (ou sem resposta em 5 s) 21 H --> P : 503 auth service unavailable 22 else 400 ou 401 23 AuthSvc --> H : token malformado / sessão não existe 24 H --> P : 401 invalid token 25 else 200 26 AuthSvc --> H : {"Username": "ana"} 27 H -> H : decodifica JSON 28 alt JSON inválido 29 H --> P : 400 30 else username no corpo diferente de "ana" 31 H --> P : 403 cannot act on behalf of another user 32 else corpo válido (username = dono do token) 33 H -> Ev : GET /event/{event_id}\nAuthorization: Bearer <token> 34 alt evento não existe 35 Ev --> H : 404 36 H --> P : 404 event service: 404 37 else serviço de eventos fora do ar ou 5xx 38 H --> P : 503 39 else 200 40 Ev --> H : {"id": 1, "name": "..."} 41 H -> Repo : NewSignup(username, event_id) 42 activate Repo 43 Repo -> SDb : INSERT ... ON CONFLICT (event_id, username) DO NOTHING 44 SDb --> Repo : linhas afetadas 45 alt 0 linhas 46 Repo --> H : errDuplicate 47 H --> P : 409 already signed up for this event 48 else 1 linha 49 Repo --> H : id 50 H --> P : 201 {"id": id, "username": "ana",\n"event_id": 1, "presence_confirmed": 0} 51 end 52 deactivate Repo 53 end 54 end 55 end 56 end 57 deactivate H 58 59 @enduml