-
Notifications
You must be signed in to change notification settings - Fork 0
/
sns.go
38 lines (29 loc) · 865 Bytes
/
sns.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package recorder
import (
"github.com/aws/aws-sdk-go/service/sns"
"github.com/aws/aws-sdk-go/service/sns/snsiface"
"github.com/go-spectest/spectest"
)
const source = "SNS"
// NewSNS wraps an SNS client and records all requests and responses.
func NewSNS(cli snsiface.SNSAPI, recorder *spectest.Recorder) snsiface.SNSAPI {
return &snsRecorder{
SNSAPI: cli,
recorder: recorder,
}
}
type snsRecorder struct {
snsiface.SNSAPI
recorder *spectest.Recorder
}
// Publish records the Publish request and response.
func (r snsRecorder) Publish(input *sns.PublishInput) (*sns.PublishOutput, error) {
recordInput(r.recorder, source, "PublishInput", input.String())
output, err := r.SNSAPI.Publish(input)
var body string
if output != nil {
body = output.String()
}
recordOutput(r.recorder, source, "PublishOutput", body, nil)
return output, err
}