Skip to content
This repository was archived by the owner on Oct 12, 2021. It is now read-only.

Commit d623398

Browse files
author
Pablo Mercado
authored
Merge pull request #126 from triggermesh/task/replace-frequency-with-interval
HTTP Poller: replace frequency with interval
2 parents eeb7dc2 + b28c3ea commit d623398

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

config/300-httppollersource.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ spec:
9292
type: object
9393
additionalProperties:
9494
type: string
95-
frequency:
96-
description: Polling frequency duration.
95+
interval:
96+
description: Polling interval.
9797
type: string
9898
sink:
9999
description: Reference to an event sink.
@@ -143,7 +143,7 @@ spec:
143143
- eventType
144144
- method
145145
- endpoint
146-
- frequency
146+
- interval
147147
- sink
148148
status:
149149
description: Status of the event source.

config/samples/httppollersource.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
eventSource: gov.weather
2424
endpoint: https://api.weather.gov/alerts/active?area=KS
2525
method: GET
26-
frequency: 20s
26+
interval: 20s
2727
sink:
2828
ref:
2929
apiVersion: serving.knative.dev/v1

pkg/adapter/httppollersource/adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func NewAdapter(ctx context.Context, aEnv adapter.EnvConfigAccessor, ceClient cl
6767
return &httpPoller{
6868
eventType: env.EventType,
6969
eventSource: env.EventSource,
70-
frequency: env.Frequency,
70+
interval: env.Interval,
7171

7272
httpClient: httpClient,
7373
httpRequest: httpRequest,

pkg/adapter/httppollersource/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ type envAccessor struct {
3939
BasicAuthUsername string `envconfig:"HTTPPOLLER_BASICAUTH_USERNAME"`
4040
BasicAuthPassword string `envconfig:"HTTPPOLLER_BASICAUTH_PASSWORD"`
4141
Headers map[string]string `envconfig:"HTTPPOLLER_HEADERS"`
42-
Frequency time.Duration `envconfig:"HTTPPOLLER_FREQUENCY" required:"true"`
42+
Interval time.Duration `envconfig:"HTTPPOLLER_INTERVAL" required:"true"`
4343
}

pkg/adapter/httppollersource/httppoller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
type httpPoller struct {
3434
eventType string
3535
eventSource string
36-
frequency time.Duration
36+
interval time.Duration
3737

3838
ceClient cloudevents.Client
3939

@@ -54,7 +54,7 @@ func (h *httpPoller) Start(ctx context.Context) error {
5454
// setup context for the request object.
5555
h.httpRequest = h.httpRequest.Clone(ctx)
5656

57-
t := time.NewTicker(h.frequency)
57+
t := time.NewTicker(h.interval)
5858

5959
for {
6060
select {

pkg/adapter/httppollersource/httppoller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func TestHTTPPollerRequests(t *testing.T) {
151151
p := httpPoller{
152152
eventType: tEventType,
153153
eventSource: tEventSource,
154-
frequency: 5 * time.Second,
154+
interval: 5 * time.Second,
155155

156156
ceClient: ceClient,
157157
httpRequest: httpRequest,

pkg/apis/sources/v1alpha1/httppollersource_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ type HTTPPollerSourceSpec struct {
8383
// +optional
8484
BasicAuthPassword *ValueFromField `json:"basicAuthPassword,omitempty"`
8585

86-
// Headers to be included at HTTP requests
86+
// Headers to be included at HTTP requests.
8787
// +optional
8888
Headers map[string]string `json:"headers,omitempty"`
8989

90-
// Frequency polling the endpoint
91-
Frequency tmapis.Duration `json:"frequency"`
90+
// Interval between polling requests.
91+
Interval tmapis.Duration `json:"interval"`
9292
}
9393

9494
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

pkg/reconciler/httppollersource/adapter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const (
4444
envHTTPPollerBasicAuthUsername = "HTTPPOLLER_BASICAUTH_USERNAME"
4545
envHTTPPollerBasicAuthPassword = "HTTPPOLLER_BASICAUTH_PASSWORD"
4646
envHTTPPollerHeaders = "HTTPPOLLER_HEADERS"
47-
envHTTPPollerFrequency = "HTTPPOLLER_FREQUENCY"
47+
envHTTPPollerInterval = "HTTPPOLLER_INTERVAL"
4848
)
4949

5050
// adapterConfig contains properties used to configure the source's adapter.
@@ -106,8 +106,8 @@ func makeHTTPPollerEnvs(src *v1alpha1.HTTPPollerSource) []corev1.EnvVar {
106106
Name: envHTTPPollerSkipVerify,
107107
Value: strconv.FormatBool(skipVerify),
108108
}, {
109-
Name: envHTTPPollerFrequency,
110-
Value: src.Spec.Frequency.String(),
109+
Name: envHTTPPollerInterval,
110+
Value: src.Spec.Interval.String(),
111111
}}
112112

113113
if src.Spec.Headers != nil {

pkg/reconciler/httppollersource/reconciler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func newEventSource() *v1alpha1.HTTPPollerSource {
8080
EventType: "test-type",
8181
Endpoint: *endpoint,
8282
Method: "GET",
83-
Frequency: tmapis.Duration(time.Second * 5),
83+
Interval: tmapis.Duration(time.Second * 5),
8484
SkipVerify: &skipVerify,
8585
Headers: map[string]string{
8686
"h1": "v1",

0 commit comments

Comments
 (0)