Skip to content

Commit

Permalink
Performance image code porting to sdk-go v2 (#3269)
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
  • Loading branch information
slinkydeveloper authored Jun 4, 2020
1 parent 3bb8f57 commit 36ed1b3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
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)
}

0 comments on commit 36ed1b3

Please sign in to comment.