-
Notifications
You must be signed in to change notification settings - Fork 214
/
alias.go
181 lines (126 loc) · 4.82 KB
/
alias.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
Copyright 2021 The CloudEvents Authors
SPDX-License-Identifier: Apache-2.0
*/
// Package v2 reexports a subset of the SDK v2 API.
package v2
// Package cloudevents alias' common functions and types to improve discoverability and reduce
// the number of imports for simple HTTP clients.
import (
"github.com/cloudevents/sdk-go/v2/binding"
"github.com/cloudevents/sdk-go/v2/client"
"github.com/cloudevents/sdk-go/v2/context"
"github.com/cloudevents/sdk-go/v2/event"
"github.com/cloudevents/sdk-go/v2/protocol"
"github.com/cloudevents/sdk-go/v2/protocol/http"
"github.com/cloudevents/sdk-go/v2/types"
)
// Client
type ClientOption client.Option
type Client = client.Client
// Event
type Event = event.Event
type Result = protocol.Result
// Context
type EventContext = event.EventContext
type EventContextV1 = event.EventContextV1
type EventContextV03 = event.EventContextV03
// Custom Types
type Timestamp = types.Timestamp
type URIRef = types.URIRef
// HTTP Protocol
type HTTPOption http.Option
type HTTPProtocol = http.Protocol
// Encoding
type Encoding = binding.Encoding
// Message
type Message = binding.Message
const (
// ReadEncoding
ApplicationXML = event.ApplicationXML
ApplicationJSON = event.ApplicationJSON
TextPlain = event.TextPlain
ApplicationCloudEventsJSON = event.ApplicationCloudEventsJSON
ApplicationCloudEventsBatchJSON = event.ApplicationCloudEventsBatchJSON
Base64 = event.Base64
// Event Versions
VersionV1 = event.CloudEventsVersionV1
VersionV03 = event.CloudEventsVersionV03
// Encoding
EncodingBinary = binding.EncodingBinary
EncodingStructured = binding.EncodingStructured
)
var (
// ContentType Helpers
StringOfApplicationJSON = event.StringOfApplicationJSON
StringOfApplicationXML = event.StringOfApplicationXML
StringOfTextPlain = event.StringOfTextPlain
StringOfApplicationCloudEventsJSON = event.StringOfApplicationCloudEventsJSON
StringOfApplicationCloudEventsBatchJSON = event.StringOfApplicationCloudEventsBatchJSON
StringOfBase64 = event.StringOfBase64
// Client Creation
NewClient = client.New
NewClientHTTP = client.NewHTTP
// Deprecated: please use New with the observability options.
NewClientObserved = client.NewObserved
// Deprecated: Please use NewClientHTTP with the observability options.
NewDefaultClient = client.NewDefault
NewHTTPReceiveHandler = client.NewHTTPReceiveHandler
// Client Options
WithEventDefaulter = client.WithEventDefaulter
WithUUIDs = client.WithUUIDs
WithTimeNow = client.WithTimeNow
// Deprecated: this is now noop and will be removed in future releases.
WithTracePropagation = client.WithTracePropagation()
// Event Creation
NewEvent = event.New
// Results
NewResult = protocol.NewResult
ResultIs = protocol.ResultIs
ResultAs = protocol.ResultAs
// Receipt helpers
NewReceipt = protocol.NewReceipt
ResultACK = protocol.ResultACK
ResultNACK = protocol.ResultNACK
IsACK = protocol.IsACK
IsNACK = protocol.IsNACK
IsUndelivered = protocol.IsUndelivered
// HTTP Results
NewHTTPResult = http.NewResult
NewHTTPRetriesResult = http.NewRetriesResult
// Message Creation
ToMessage = binding.ToMessage
// Event Creation
NewEventFromHTTPRequest = http.NewEventFromHTTPRequest
NewEventFromHTTPResponse = http.NewEventFromHTTPResponse
// HTTP Messages
WriteHTTPRequest = http.WriteRequest
// Context
ContextWithTarget = context.WithTarget
TargetFromContext = context.TargetFrom
ContextWithRetriesConstantBackoff = context.WithRetriesConstantBackoff
ContextWithRetriesLinearBackoff = context.WithRetriesLinearBackoff
ContextWithRetriesExponentialBackoff = context.WithRetriesExponentialBackoff
WithEncodingBinary = binding.WithForceBinary
WithEncodingStructured = binding.WithForceStructured
// Custom Types
ParseTimestamp = types.ParseTimestamp
ParseURIRef = types.ParseURIRef
ParseURI = types.ParseURI
// HTTP Protocol
NewHTTP = http.New
// HTTP Protocol Options
WithTarget = http.WithTarget
WithHeader = http.WithHeader
WithShutdownTimeout = http.WithShutdownTimeout
//WithEncoding = http.WithEncoding
//WithStructuredEncoding = http.WithStructuredEncoding // TODO: expose new way
WithPort = http.WithPort
WithPath = http.WithPath
WithMiddleware = http.WithMiddleware
WithListener = http.WithListener
WithRoundTripper = http.WithRoundTripper
WithGetHandlerFunc = http.WithGetHandlerFunc
WithOptionsHandlerFunc = http.WithOptionsHandlerFunc
WithDefaultOptionsHandlerFunc = http.WithDefaultOptionsHandlerFunc
)