feat: complete cmpp gateway delivery recovery workflows
This commit is contained in:
@@ -25,19 +25,20 @@ type Envelope struct {
|
||||
|
||||
type SubmitCommand struct {
|
||||
Envelope
|
||||
TenantID string `json:"tenantId"`
|
||||
ApplicationID string `json:"applicationId"`
|
||||
TaskID string `json:"taskId,omitempty"`
|
||||
SubmitID string `json:"submitId"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
Content string `json:"content"`
|
||||
Signature string `json:"signature"`
|
||||
TemplateID string `json:"templateId"`
|
||||
BillingUnits int `json:"billingUnits"`
|
||||
QueuePriority string `json:"queuePriority"`
|
||||
Route Route `json:"route"`
|
||||
CMPP CMPP `json:"cmpp"`
|
||||
Retry Retry `json:"retry"`
|
||||
TenantID string `json:"tenantId"`
|
||||
ApplicationID string `json:"applicationId"`
|
||||
TaskID string `json:"taskId,omitempty"`
|
||||
SubmitID string `json:"submitId"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
Content string `json:"content"`
|
||||
Signature string `json:"signature"`
|
||||
TemplateID string `json:"templateId"`
|
||||
BillingUnits int `json:"billingUnits"`
|
||||
QueuePriority string `json:"queuePriority"`
|
||||
Route Route `json:"route"`
|
||||
CMPP CMPP `json:"cmpp"`
|
||||
Upstream UpstreamConfig `json:"upstream"`
|
||||
Retry Retry `json:"retry"`
|
||||
}
|
||||
|
||||
type Route struct {
|
||||
@@ -57,6 +58,16 @@ type CMPP struct {
|
||||
FeeType string `json:"feeType,omitempty"`
|
||||
}
|
||||
|
||||
type UpstreamConfig struct {
|
||||
GatewayHost string `json:"gatewayHost"`
|
||||
GatewayPort int `json:"gatewayPort"`
|
||||
Account string `json:"account"`
|
||||
PasswordCipher string `json:"passwordCipher"`
|
||||
CMPPVersion string `json:"cmppVersion"`
|
||||
DesiredConnections int `json:"desiredConnections,omitempty"`
|
||||
WindowSize int `json:"windowSize,omitempty"`
|
||||
}
|
||||
|
||||
type Retry struct {
|
||||
Attempt int `json:"attempt"`
|
||||
MaxAttempts int `json:"maxAttempts"`
|
||||
@@ -70,12 +81,25 @@ type SubmitResult struct {
|
||||
ErrorCode string `json:"errorCode,omitempty"`
|
||||
ErrorMessage string `json:"errorMessage,omitempty"`
|
||||
SubmittedAt time.Time `json:"submittedAt"`
|
||||
Segments []SubmitSegmentResult `json:"segments,omitempty"`
|
||||
}
|
||||
|
||||
type SubmitSegmentResult struct {
|
||||
SegmentTotal int `json:"segmentTotal"`
|
||||
SegmentIndex int `json:"segmentIndex"`
|
||||
SequenceID uint32 `json:"sequenceId"`
|
||||
GatewayMessageID string `json:"gatewayMessageId"`
|
||||
SubmitStatus string `json:"submitStatus"`
|
||||
ErrorCode string `json:"errorCode,omitempty"`
|
||||
ErrorMessage string `json:"errorMessage,omitempty"`
|
||||
SubmittedAt time.Time `json:"submittedAt"`
|
||||
}
|
||||
|
||||
type ReceiptEvent struct {
|
||||
Envelope
|
||||
SequenceID uint32 `json:"sequenceId"`
|
||||
GatewayMessageID string `json:"gatewayMessageId"`
|
||||
PhoneNumber string `json:"phoneNumber,omitempty"`
|
||||
ReceiptStatus string `json:"receiptStatus"`
|
||||
RawStatus string `json:"rawStatus"`
|
||||
ErrorCode string `json:"errorCode,omitempty"`
|
||||
|
||||
@@ -34,6 +34,15 @@ func TestSubmitCommandUnmarshalsQueuePriority(t *testing.T) {
|
||||
"registeredDelivery": 1,
|
||||
"msgFmt": 8
|
||||
},
|
||||
"upstream": {
|
||||
"gatewayHost": "127.0.0.1",
|
||||
"gatewayPort": 17890,
|
||||
"account": "account-a",
|
||||
"passwordCipher": "secret",
|
||||
"cmppVersion": "3.0",
|
||||
"desiredConnections": 2,
|
||||
"windowSize": 16
|
||||
},
|
||||
"retry": {
|
||||
"attempt": 0,
|
||||
"maxAttempts": 3
|
||||
@@ -47,4 +56,10 @@ func TestSubmitCommandUnmarshalsQueuePriority(t *testing.T) {
|
||||
if command.QueuePriority != "priority" {
|
||||
t.Fatalf("QueuePriority = %q, want priority", command.QueuePriority)
|
||||
}
|
||||
if command.Upstream.GatewayHost != "127.0.0.1" || command.Upstream.Account != "account-a" {
|
||||
t.Fatalf("unexpected upstream config: %+v", command.Upstream)
|
||||
}
|
||||
if command.Upstream.DesiredConnections != 2 || command.Upstream.WindowSize != 16 {
|
||||
t.Fatalf("unexpected upstream window config: %+v", command.Upstream)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user