Files
houston-be/common/util/requestStatus/request_status.go
Vijay Joshi 288a7f8457 INFRA-3664 : Make get users in conversation api more performant, add api to sync incident users, module to track request statuses and remove old add incident-user api (#451)
* INFRA-3664 : Make get users in conversation api more performant

* INFRA-3664 : Add apis for incident user sync and get users in incident performance improvements

* INFRA-3664 : Self review

* INFRA-3664 : Add migration script

* INFRA-3664 : Review comments

* INFRA-3664 : Constant chanes

* INFRA-3664 : Add rate limit constants

* INFRA-3664 : Add rate limit constants

* INFRA-3664 : Fix failing tests

* INFRA-3664 : Add UT's
2024-08-29 11:52:56 +05:30

40 lines
889 B
Go

package requestStatus
type RequestType string
const SyncIncidentUsersRequestType RequestType = "SYNC_INCIDENT_USERS"
type RequestStatus interface {
Value() string
IsTerminal() bool
}
type Pending struct{}
func (Pending) Value() string { return "PENDING" }
func (Pending) IsTerminal() bool { return false }
type Success struct{}
func (Success) Value() string { return "SUCCESS" }
func (Success) IsTerminal() bool { return true }
type Failed struct{}
func (Failed) Value() string { return "FAILED" }
func (Failed) IsTerminal() bool { return true }
func GetAllStatusValuesByTerminalState(isTerminal bool) []string {
var statusValues []string
allStatuses := []RequestStatus{Pending{}, Success{}, Failed{}}
for _, status := range allStatuses {
if status.IsTerminal() == isTerminal {
statusValues = append(statusValues, status.Value())
}
}
return statusValues
}