Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance image code porting to sdk-go v2 #3269

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/performance/infra/receiver/id_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

package receiver

import cloudevents "github.com/cloudevents/sdk-go"
import cloudevents "github.com/cloudevents/sdk-go/v2"

// IdExtractor is used by the receiver to establish the id of the received event
type IdExtractor func(event cloudevents.Event) string
Expand Down
6 changes: 2 additions & 4 deletions test/performance/infra/receiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import (
"fmt"
"log"
"net"
"net/http"
"runtime"
"time"

cloudevents "github.com/cloudevents/sdk-go"
cloudevents "github.com/cloudevents/sdk-go/v2"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"

Expand Down Expand Up @@ -159,7 +158,7 @@ func (r *Receiver) startCloudEventsReceiver(ctx context.Context) error {
}

// processReceiveEvent processes the event received by the CloudEvents receiver.
func (r *Receiver) processReceiveEvent(event cloudevents.Event, resp *cloudevents.EventResponse) {
func (r *Receiver) processReceiveEvent(event cloudevents.Event) {
t := r.typeExtractor(event)
switch t {
case common.MeasureEventType:
Expand All @@ -173,7 +172,6 @@ func (r *Receiver) processReceiveEvent(event cloudevents.Event, resp *cloudevent
r.endCh <- struct{}{}
})
}
resp.Status = http.StatusAccepted
}

// waitForPortAvailable waits until the given TCP port is available.
Expand Down
2 changes: 1 addition & 1 deletion test/performance/infra/receiver/type_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

package receiver

import cloudevents "github.com/cloudevents/sdk-go"
import cloudevents "github.com/cloudevents/sdk-go/v2"

// TypeExtractor is used by the receiver to establish the type of the received event
type TypeExtractor func(event cloudevents.Event) string
Expand Down
14 changes: 6 additions & 8 deletions test/performance/infra/sender/http_load_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import (
"net/http"
"time"

cloudevents "github.com/cloudevents/sdk-go"
"github.com/cloudevents/sdk-go/pkg/cloudevents/client"
cloudevents "github.com/cloudevents/sdk-go/v2"
"github.com/golang/protobuf/ptypes"
"github.com/google/uuid"
"github.com/rogpeppe/fastuuid"
Expand Down Expand Up @@ -117,7 +116,7 @@ type HttpLoadGenerator struct {

warmupAttacker *vegeta.Attacker
paceAttacker *vegeta.Attacker
ceClient client.Client
ceClient cloudevents.Client
}

func NewHttpLoadGeneratorFactory(sinkUrl string, minWorkers uint64) LoadGeneratorFactory {
Expand Down Expand Up @@ -186,9 +185,8 @@ func vegetaAttackerTransport() *http.Transport {
}
}

func newCloudEventsClient(sinkUrl string) (client.Client, error) {
t, err := cloudevents.NewHTTPTransport(
cloudevents.WithBinaryEncoding(),
func newCloudEventsClient(sinkUrl string) (cloudevents.Client, error) {
t, err := cloudevents.NewHTTP(
cloudevents.WithTarget(sinkUrl),
)
if err != nil {
Expand Down Expand Up @@ -219,7 +217,7 @@ func (h HttpLoadGenerator) SendGCEvent() {
event.SetType(common.GCEventType)
event.SetSource(h.eventSource)

_, _, _ = h.ceClient.Send(context.TODO(), event)
_ = h.ceClient.Send(context.TODO(), event)
}

func (h HttpLoadGenerator) SendEndEvent() {
Expand All @@ -229,5 +227,5 @@ func (h HttpLoadGenerator) SendEndEvent() {
event.SetType(common.EndEventType)
event.SetSource(h.eventSource)

_, _, _ = h.ceClient.Send(context.TODO(), event)
_ = h.ceClient.Send(context.TODO(), event)
}