Skip to content

Commit

Permalink
Merge branch 'master' into fix_spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
yaron2 committed Mar 21, 2021
2 parents e3a726b + 0340225 commit 58840b5
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 22 deletions.
7 changes: 5 additions & 2 deletions go.mod
Expand Up @@ -8,9 +8,10 @@ require (
github.com/AdhityaRamadhanus/fasthttpcors v0.0.0-20170121111917-d4c07198763a
github.com/PuerkitoBio/purell v1.1.1
github.com/agrea/ptr v0.0.0-20180711073057-77a518d99b7b
github.com/andybalholm/brotli v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.0
github.com/dapr/components-contrib v1.0.1-0.20210318212214-192461889c55
github.com/fasthttp/router v1.3.5
github.com/fasthttp/router v1.3.8
github.com/fsnotify/fsnotify v1.4.9
github.com/ghodss/yaml v1.0.0
github.com/golang/protobuf v1.4.3
Expand All @@ -24,6 +25,7 @@ require (
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea
github.com/json-iterator/go v1.1.10
github.com/kelseyhightower/envconfig v1.4.0
github.com/klauspost/compress v1.11.8 // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
github.com/mitchellh/mapstructure v1.3.3
github.com/nats-io/nats-streaming-server v0.21.1 // indirect
Expand All @@ -33,10 +35,11 @@ require (
github.com/prometheus/client_golang v1.8.0
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.14.0
github.com/savsgio/gotils v0.0.0-20210225112730-595c7e5a8a7a // indirect
github.com/sendgrid/rest v2.6.2+incompatible // indirect
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.6.1
github.com/valyala/fasthttp v1.19.0
github.com/valyala/fasthttp v1.21.0
go.opencensus.io v0.22.5
go.opentelemetry.io/otel v0.13.0
go.uber.org/atomic v1.6.0
Expand Down
16 changes: 11 additions & 5 deletions go.sum
Expand Up @@ -182,8 +182,9 @@ github.com/alicebob/miniredis/v2 v2.13.3/go.mod h1:uS970Sw5Gs9/iK3yBg0l9Uj9s25wX
github.com/aliyun/aliyun-oss-go-sdk v2.0.7+incompatible h1:HXvOJsZw8JT/ldxjX74Aq4H2IY4ojV/mXMDPWFitpv8=
github.com/aliyun/aliyun-oss-go-sdk v2.0.7+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc=
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/apache/pulsar-client-go v0.1.0 h1:2BFZztxtNgFyOzBc+5On84CX6aIZW5xwh7KM0MWigGI=
github.com/apache/pulsar-client-go v0.1.0/go.mod h1:G+CQVHnh2EPfNEQXOuisIDAyPMiKnzz4Vim/kjtj4U4=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
Expand Down Expand Up @@ -360,8 +361,9 @@ github.com/fasthttp-contrib/sessions v0.0.0-20160905201309-74f6ac73d5d5 h1:M4CVM
github.com/fasthttp-contrib/sessions v0.0.0-20160905201309-74f6ac73d5d5/go.mod h1:MQXNGeXkpojWTxbN7vXoE3f7EmlA11MlJbsrJpVBINA=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
github.com/fasthttp/router v1.3.2/go.mod h1:athTSKMdel0Qhh3W4nB8qn+EPYuyj6YZMUo6ZcXWTgc=
github.com/fasthttp/router v1.3.5 h1:XGZZtcYUH+9ZoLxKhwF66F8sGnMT+Jg00j0JdVzwmDA=
github.com/fasthttp/router v1.3.5/go.mod h1:BylQKgvh6YQkR0mvL60+HJyTaGwcn5d8UFNweOb/Nw8=
github.com/fasthttp/router v1.3.8 h1:2ByFINIskXMu8aim/JmZ8WPU7FD4FjaXdUE/tBoAgDI=
github.com/fasthttp/router v1.3.8/go.mod h1:DQBvuHvYbn3SUN6pGjwjPbpCNpWfCFc5Ipn/Fj6XxFc=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
Expand Down Expand Up @@ -771,8 +773,9 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.9.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.10.7 h1:7rix8v8GpI3ZBb0nSozFRgbtXKv+hOe+qfEpZqybrAg=
github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.11.8 h1:difgzQsp5mdAz9v8lm3P/I+EpDKMU/6uTMw1y1FObuo=
github.com/klauspost/compress v1.11.8/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
Expand Down Expand Up @@ -1049,8 +1052,10 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/savsgio/gotils v0.0.0-20200616100644-13ff1fd2c28c/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
github.com/savsgio/gotils v0.0.0-20210105085219-0567298fdcac h1:5pr1F6tcjeIKPKlrQZW6hzB0WxZge7SkkYVGG/e5pLY=
github.com/savsgio/gotils v0.0.0-20210105085219-0567298fdcac/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
github.com/savsgio/gotils v0.0.0-20210217112953-d4a072536008/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
github.com/savsgio/gotils v0.0.0-20210225112730-595c7e5a8a7a h1:9AQ3IfP72fCdbYAJNNwovzXrarhaWtxosEuN1fpent0=
github.com/savsgio/gotils v0.0.0-20210225112730-595c7e5a8a7a/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sendgrid/rest v2.4.1+incompatible/go.mod h1:kXX7q3jZtJXK5c5qK83bSGMdV6tsOE70KbHoqJls4lE=
Expand Down Expand Up @@ -1133,8 +1138,9 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
github.com/valyala/fasthttp v1.16.0/go.mod h1:YOKImeEosDdBPnxc0gy7INqi3m1zK6A+xl6TwOBhHCA=
github.com/valyala/fasthttp v1.19.0 h1:PfTS4PeH3xDr3WomrDS2ID8lU2GskK1xS3YG6gIpibU=
github.com/valyala/fasthttp v1.19.0/go.mod h1:jjraHZVbKOXftJfsOYoAjaeygpj5hr8ermTRJNroD7A=
github.com/valyala/fasthttp v1.21.0 h1:fJjaQ7cXdaSF9vDBujlHLDGj7AgoMTMIXvICeePzYbU=
github.com/valyala/fasthttp v1.21.0/go.mod h1:jjraHZVbKOXftJfsOYoAjaeygpj5hr8ermTRJNroD7A=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.1.0 h1:RZqt0yGBsps8NGvLSGW804QQqCUYYLsaOjTVHy1Ocw4=
github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
Expand Down
8 changes: 4 additions & 4 deletions pkg/components/standalone_loader.go
Expand Up @@ -8,7 +8,6 @@ package components
import (
"bufio"
"bytes"
"fmt"
"io"
"io/ioutil"
"path/filepath"
Expand Down Expand Up @@ -48,14 +47,15 @@ func (s *StandaloneComponents) LoadComponents() ([]components_v1alpha1.Component

for _, file := range files {
if !file.IsDir() && s.isYaml(file.Name()) {
b, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", dir, file.Name()))
path := filepath.Join(dir, file.Name())

b, err := ioutil.ReadFile(path)
if err != nil {
log.Warnf("error reading file %s/%s : %s", dir, file.Name(), err)
log.Warnf("error reading file %s : %s", path, err)
continue
}

components, _ := s.decodeYaml(fmt.Sprintf("%s/%s", dir, file.Name()), b)
components, _ := s.decodeYaml(path, b)
list = append(list, components...)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/diagnostics/grpc_tracing.go
Expand Up @@ -80,7 +80,7 @@ func GRPCTraceUnaryServerInterceptor(appID string, spec config.TracingSpec) grpc
}
}

// userDefinedMetadata returns dapr- prefixed header from incoming metdata.
// userDefinedMetadata returns dapr- prefixed header from incoming metadata.
// Users can add dapr- prefixed headers that they want to see in span attributes.
func userDefinedMetadata(ctx context.Context) map[string]string {
var daprMetadata = map[string]string{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/diagnostics/http_tracing.go
Expand Up @@ -69,7 +69,7 @@ func HTTPTraceMiddleware(next fasthttp.RequestHandler, appID string, spec config
}
}

// userDefinedHTTPHeaders returns dapr- prefixed header from incoming metdata.
// userDefinedHTTPHeaders returns dapr- prefixed header from incoming metadata.
// Users can add dapr- prefixed headers that they want to see in span attributes.
func userDefinedHTTPHeaders(reqCtx *fasthttp.RequestCtx) map[string]string {
var m = map[string]string{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/diagnostics/tracing.go
Expand Up @@ -29,7 +29,7 @@ const (
// daprInternalSpanAttrPrefix is the internal span attribution prefix.
// Middleware will not populate it if the span key starts with this prefix.
daprInternalSpanAttrPrefix = "__dapr."
// daprAPISpanNameInternal is the internal attributation, but not populated
// daprAPISpanNameInternal is the internal attribution, but not populated
// to span attribution.
daprAPISpanNameInternal = daprInternalSpanAttrPrefix + "spanname"

Expand Down
3 changes: 1 addition & 2 deletions pkg/http/api.go
Expand Up @@ -1195,8 +1195,7 @@ func (a *api) onPublish(reqCtx *fasthttp.RequestCtx) {
}

topic := reqCtx.UserValue(topicParam).(string)
// FIXME: isn't it "" instead?
if topic == "/" {
if topic == "" {
msg := NewErrorResponse("ERR_TOPIC_EMPTY", fmt.Sprintf(messages.ErrTopicEmpty, pubsubName))
respondWithError(reqCtx, fasthttp.StatusNotFound, msg)
log.Debug(msg)
Expand Down
4 changes: 2 additions & 2 deletions pkg/http/api_test.go
Expand Up @@ -139,14 +139,14 @@ func TestPubSubEndpoints(t *testing.T) {
}
})

t.Run("Publish without topic name ending in // - 404", func(t *testing.T) {
t.Run("Publish with topic name '/' - 204", func(t *testing.T) {
apiPath := fmt.Sprintf("%s/publish/pubsubname//", apiVersionV1)
testMethods := []string{"POST", "PUT"}
for _, method := range testMethods {
// act
resp := fakeServer.DoRequest(method, apiPath, []byte("{\"key\": \"value\"}"), nil)
// assert
assert.Equal(t, 404, resp.StatusCode, "unexpected success publishing with %s", method)
assert.Equal(t, 204, resp.StatusCode, "success publishing with %s", method)
}
})

Expand Down
5 changes: 5 additions & 0 deletions pkg/messaging/direct_messaging.go
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/dapr/dapr/pkg/config"
diag "github.com/dapr/dapr/pkg/diagnostics"
diag_utils "github.com/dapr/dapr/pkg/diagnostics/utils"
"github.com/dapr/dapr/pkg/logger"
"github.com/dapr/dapr/pkg/modes"
"github.com/dapr/dapr/pkg/retry"
"github.com/dapr/dapr/utils"
Expand All @@ -29,6 +30,8 @@ import (
internalv1pb "github.com/dapr/dapr/pkg/proto/internals/v1"
)

var log = logger.NewLogger("dapr.runtime.direct_messaging")

// messageClientConnection is the function type to connect to the other
// applications to send the message using service invocation.
type messageClientConnection func(address, id string, namespace string, skipTLS, recreateIfExists, enableSSL bool) (*grpc.ClientConn, error)
Expand Down Expand Up @@ -123,6 +126,8 @@ func (d *directMessaging) invokeWithRetry(
if err == nil {
return resp, nil
}
log.Debugf("retry count: %d, grpc call failed, ns: %s, addr: %s, appid: %s, err: %s",
i+1, app.namespace, app.address, app.id, err.Error())
time.Sleep(backoffInterval)

code := status.Code(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/runtime/pubsub/subscriptions.go
Expand Up @@ -3,10 +3,10 @@ package pubsub
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"

subscriptionsapi "github.com/dapr/dapr/pkg/apis/subscriptions/v1alpha1"
"github.com/dapr/dapr/pkg/channel"
Expand Down Expand Up @@ -106,7 +106,7 @@ func DeclarativeSelfHosted(componentsPath string, log logger.Logger) []Subscript

for _, f := range files {
if !f.IsDir() {
filePath := fmt.Sprintf("%s/%s", componentsPath, f.Name())
filePath := filepath.Join(componentsPath, f.Name())
b, err := ioutil.ReadFile(filePath)
if err != nil {
log.Errorf("failed to read file %s: %s", filePath, err)
Expand Down
5 changes: 3 additions & 2 deletions pkg/runtime/pubsub/subscriptions_test.go
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"

subscriptionsapi "github.com/dapr/dapr/pkg/apis/subscriptions/v1alpha1"
Expand Down Expand Up @@ -56,15 +57,15 @@ func writeSubscriptionToDisk(subscription subscriptionsapi.Subscription, filePat
}

func TestDeclarativeSubscriptions(t *testing.T) {
dir := "./components"
dir := filepath.Join(".", "components")
os.Mkdir(dir, 0777)
defer os.RemoveAll(dir)

t.Run("load single valid subscription", func(t *testing.T) {
s := testDeclarativeSubscription()
s.Scopes = []string{"scope1"}

filePath := "./components/sub.yaml"
filePath := filepath.Join(".", "components", "sub.yaml")
writeSubscriptionToDisk(s, filePath)

subs := DeclarativeSelfHosted(dir, log)
Expand Down

0 comments on commit 58840b5

Please sign in to comment.