Skip to content

Commit

Permalink
feat: make meta just plain string
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Sep 17, 2021
1 parent 8fe4116 commit ae8ad3f
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 269 deletions.
8 changes: 7 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ linters:
- typecheck
- unparam
- unused
- varcheck
- varcheck
issues:
exclude-rules:
- linters:
- staticcheck
# SA1029: should not use built-in type string as key for value; define your own type to avoid collisions
text: "SA1029:"
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ FROM golang:1.16-alpine AS golang1-16
COPY --from=builder /tmp/dumb-init /dumb-init
RUN chmod +x /dumb-init
RUN mkdir /.cache
ENV GO111MODULE=off
ADD sdks/golang /go/src/github.com/argoproj-labs/argo-dataflow/sdks/golang
ADD runtimes/golang1-16 /workspace
RUN chown -R 9653 /.cache /workspace
WORKDIR /workspace
USER 9653:9653
RUN go mod download
RUN go mod tidy
RUN go build ./...
ENTRYPOINT ["/dumb-init", "--"]
CMD ["/workspace/entrypoint.sh"]
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ pre-commit: codegen proto test install runner testapi lint start

codegen: generate manifests examples tests
go generate ./...
cd runtimes/golang1-16 && go get -u github.com/argoproj-labs/argo-dataflow && go mod tidy
cd examples/git && go get -u github.com/argoproj-labs/argo-dataflow && go mod tidy

$(GOBIN)/goreman:
go install github.com/mattn/[email protected]
Expand Down
22 changes: 9 additions & 13 deletions api/v1alpha1/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@ import (
"time"
)

type meta struct{ string }

func (m meta) String() string { return m.string }

var (
// MetaID is a unique ID for the message.
// Required.
// https://github.com/cloudevents/spec/blob/master/spec.md#id
MetaID = meta{"id"}
MetaID = "dataflow-id"
// MetaSource is the source of the messages as a Unique Resource Identifier (URI).
// Required.
// https://github.com/cloudevents/spec/blob/master/spec.md#source-1
MetaSource = meta{"source"}
MetaSource = "dataflow-source"
// MetaTime is the time of the message. As meta-data, this might be different to the event-time (which might be within the message).
// For example, it might be the last-modified time of a file, but the file itself was created at another time.
// Optional.
// https://github.com/cloudevents/spec/blob/master/spec.md#time
MetaTime = meta{"time"}
MetaTime = "dataflow-time"
)

func ContextWithMeta(ctx context.Context, source, id string, time time.Time) context.Context {
Expand Down Expand Up @@ -64,17 +60,17 @@ func MetaInject(ctx context.Context, h http.Header) error {
if err != nil {
return err
}
h.Add(MetaSource.String(), source)
h.Add(MetaID.String(), id)
h.Add(MetaTime.String(), t.Format(time.RFC3339))
h.Add(MetaSource, source)
h.Add(MetaID, id)
h.Add(MetaTime, t.Format(time.RFC3339))
return nil
}

func MetaExtract(ctx context.Context, h http.Header) context.Context {
t, _ := time.Parse(time.RFC3339, h.Get(MetaTime.String()))
t, _ := time.Parse(time.RFC3339, h.Get(MetaTime))
return ContextWithMeta(ctx,
h.Get(MetaSource.String()),
h.Get(MetaID.String()),
h.Get(MetaSource),
h.Get(MetaID),
t,
)
}
5 changes: 0 additions & 5 deletions examples/git/go.mod

This file was deleted.

15 changes: 1 addition & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/argoproj-labs/argo-dataflow
go 1.16

require (
cloud.google.com/go v0.81.0 // indirect
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0
Expand All @@ -21,22 +20,16 @@ require (
github.com/go-logr/logr v0.3.0
github.com/go-sql-driver/mysql v1.6.0
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.1.2
github.com/huandu/xstrings v1.3.2 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/juju/fslock v0.0.0-20160525022230-4d5c94c67b4b
github.com/klauspost/compress v1.13.1 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mitchellh/copystructure v1.1.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/nats-io/nats-streaming-server v0.21.1
github.com/nats-io/nats.go v1.11.0
github.com/nats-io/stan.go v0.8.3
github.com/onsi/ginkgo v1.14.1
github.com/onsi/gomega v1.10.2
github.com/opentracing/opentracing-go v1.2.0
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.10.0
Expand All @@ -45,12 +38,6 @@ require (
github.com/stretchr/testify v1.7.0
github.com/uber/jaeger-client-go v2.29.1+incompatible
github.com/uber/jaeger-lib v2.4.1+incompatible
go.uber.org/zap v1.17.0 // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect
golang.org/x/tools v0.1.5 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.20.4
k8s.io/apimachinery v0.20.4
k8s.io/client-go v0.20.4
Expand Down
Loading

0 comments on commit ae8ad3f

Please sign in to comment.