Skip to content

Commit

Permalink
Delete emitter implementations
Browse files Browse the repository at this point in the history
This deletes the Zap and Tally emitter implementations from cff to
reduce the dependency footprint.
We'll keep copies of these for use internally.

This also warns users away from using WithEmitter because the API is
expected to change significantly with #11.

Resolves #2
  • Loading branch information
abhinav committed Oct 21, 2022
1 parent 5525184 commit 7e3bac8
Show file tree
Hide file tree
Showing 46 changed files with 296 additions and 301,623 deletions.
11 changes: 3 additions & 8 deletions cff.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,11 @@ func Results(results ...interface{}) Option {
//
// cff.Flow(ctx,
// ...
// cff.WithEmitter(cff.TallyEmitter(scope)),
// cff.WithEmitter(em),
// )
//
// Provide this option multiple times to connect multiple emitters.
//
// cff.Flow(ctx,
// ...
// cff.WithEmitter(cff.TallyEmitter(scope)),
// cff.WithEmitter(cff.LogEmitter(logger)),
// )
// WARNING: Do not use this API.
// We intend to replace it in an upcoming release.
//
// This is a code generation directive.
func WithEmitter(Emitter) Option {
Expand Down
15 changes: 15 additions & 0 deletions emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
)

// Emitter initializes Task, Flow, and Parallel emitters.
//
// WARNING: Do not use this API.
// We intend to replace it in an upcoming release.
type Emitter interface {
// TaskInit returns a TaskEmitter which could be memoized based on task name.
TaskInit(*TaskInfo, *DirectiveInfo) TaskEmitter
Expand All @@ -25,6 +28,9 @@ type SchedulerState = scheduler.State

// SchedulerEmitter provides observability into the state of the CFF
// scheduler.
//
// WARNING: Do not use this API.
// We intend to replace it in an upcoming release.
type SchedulerEmitter interface {
// EmitScheduler emits the state of the CFF scheduler.
EmitScheduler(s SchedulerState)
Expand Down Expand Up @@ -74,6 +80,9 @@ type ParallelInfo struct {

// FlowEmitter receives events for when flow events occur, for the purpose of
// emitting metrics.
//
// WARNING: Do not use this API.
// We intend to replace it in an upcoming release.
type FlowEmitter interface {
// FlowSuccess is called when a flow runs successfully.
FlowSuccess(context.Context)
Expand All @@ -85,6 +94,9 @@ type FlowEmitter interface {

// ParallelEmitter receives events for when parallel events occur, for the
// purpose of emitting metrics.
//
// WARNING: Do not use this API.
// We intend to replace it in an upcoming release.
type ParallelEmitter interface {
// ParallelSuccess is called when a parallel runs successfully.
ParallelSuccess(context.Context)
Expand All @@ -96,6 +108,9 @@ type ParallelEmitter interface {

// TaskEmitter receives events for when task events occur, for the purpose of
// emitting metrics.
//
// WARNING: Do not use this API.
// We intend to replace it in an upcoming release.
type TaskEmitter interface {
// TaskSuccess is called when a task runs successfully.
TaskSuccess(context.Context)
Expand Down
12 changes: 5 additions & 7 deletions emitter_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import (
"time"

"github.com/golang/mock/gomock"
"github.com/uber-go/tally"
. "go.uber.org/cff"
"go.uber.org/cff/internal/emittertest"
"go.uber.org/zap"
)

func TestEmitterStackConstruction(t *testing.T) {
Expand All @@ -22,24 +20,24 @@ func TestEmitterStackConstruction(t *testing.T) {
{
desc: "single",
give: []Emitter{
LogEmitter(zap.NewNop()),
NopEmitter(),
},
},
{
desc: "multiple",
give: []Emitter{
LogEmitter(zap.NewNop()),
NopEmitter(),
TallyEmitter(tally.NoopScope),
NopEmitter(),
NopEmitter(),
},
},
{
desc: "nested",
give: []Emitter{
LogEmitter(zap.NewNop()),
NopEmitter(),
EmitterStack(
NopEmitter(),
TallyEmitter(tally.NoopScope),
NopEmitter(),
),
},
},
Expand Down
3 changes: 0 additions & 3 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ go 1.19

require (
github.com/stretchr/testify v1.8.0
github.com/uber-go/tally v3.5.0+incompatible
go.uber.org/cff v0.1.0
go.uber.org/zap v1.23.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/twmb/murmur3 v1.1.6 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
8 changes: 0 additions & 8 deletions examples/go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand All @@ -13,18 +11,12 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg=
github.com/twmb/murmur3 v1.1.6/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
github.com/uber-go/tally v3.5.0+incompatible h1:2vIkqVrSaspifqcJh2yQjQqqpfavvmfj/ognDrBxuSg=
github.com/uber-go/tally v3.5.0+incompatible/go.mod h1:YDTIBxdXyOU/sCWilKB4bgyufu1cEi0jdVnRdxvjnmU=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY=
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
19 changes: 3 additions & 16 deletions examples/magic.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (
"fmt"
"strconv"

"github.com/uber-go/tally"
"go.uber.org/cff"
"go.uber.org/zap"
)

// Request TODO
Expand All @@ -24,11 +22,9 @@ type Response struct {
}

type fooHandler struct {
mgr *ManagerRepository
users *UserRepository
ses *SESClient
scope tally.Scope
logger *zap.Logger
mgr *ManagerRepository
users *UserRepository
ses *SESClient
}

func (h *fooHandler) HandleFoo(ctx context.Context, req *Request) (*Response, error) {
Expand All @@ -37,9 +33,6 @@ func (h *fooHandler) HandleFoo(ctx context.Context, req *Request) (*Response, er
cff.Params(req),
cff.Results(&res),
cff.Concurrency(8),
cff.WithEmitter(cff.TallyEmitter(h.scope)),
cff.WithEmitter(cff.LogEmitter(h.logger)),
cff.InstrumentFlow("HandleFoo"),

cff.Task(
func(req *Request) (*GetManagerRequest, *ListUsersRequest) {
Expand Down Expand Up @@ -67,7 +60,6 @@ func (h *fooHandler) HandleFoo(ctx context.Context, req *Request) (*Response, er
return req.LDAPGroup != "everyone"
}),
cff.FallbackWith(&ListUsersResponse{}),
cff.Instrument("FormSendEmailRequest"),
),
cff.Task(
func(mgr *GetManagerResponse, users *ListUsersResponse) []*SendEmailRequest {
Expand All @@ -80,16 +72,12 @@ func (h *fooHandler) HandleFoo(ctx context.Context, req *Request) (*Response, er
cff.Predicate(func(req *GetManagerRequest) bool {
return req.LDAPGroup != "everyone"
}),
cff.Instrument("FormSendEmailRequest"),
),
)

err = cff.Parallel(
ctx,
cff.Concurrency(2),
cff.WithEmitter(cff.TallyEmitter(h.scope)),
cff.WithEmitter(cff.LogEmitter(h.logger)),
cff.InstrumentParallel("SendParallel"),
cff.ContinueOnError(true),
cff.Tasks(
func(_ context.Context) error {
Expand All @@ -101,7 +89,6 @@ func (h *fooHandler) HandleFoo(ctx context.Context, req *Request) (*Response, er
func() error {
return SendMessage()
},
cff.Instrument("SendMsg"),
),
cff.Slice(
func(ctx context.Context, idx int, s string) error {
Expand Down
Loading

0 comments on commit 7e3bac8

Please sign in to comment.