Skip to content

Commit

Permalink
Dispatcher: Drop Choose/Procedures
Browse files Browse the repository at this point in the history
Dispatcher has a router but doesn't have to be a router itself.
  • Loading branch information
abhinav committed Dec 27, 2016
1 parent 2e5aad0 commit 0e506a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -47,6 +47,8 @@ v1.0.0-dev (unreleased)
`yarpc.ResponseHeaders` to receive response headers for the call.

- **Breaking**: Removed `yarpc.Headers` in favor of `map[string]string`.
- **Breaking**: `yarpc.Dispatcher` no longer implements the
`transport.Router` interface.
- **Breaking**: Start and Stop for Inbound and Outbound are now expected to
be idempotent.
- **Breaking**: Combine `ServiceProcedure` and `Registrant` into `Procedure`.
Expand Down
15 changes: 1 addition & 14 deletions dispatcher.go
Expand Up @@ -21,7 +21,6 @@
package yarpc

import (
"context"
"fmt"
"sync"

Expand Down Expand Up @@ -189,18 +188,6 @@ func (d *Dispatcher) ClientConfig(service string) transport.ClientConfig {
panic(noOutboundForService{Service: service})
}

// Procedures returns a list of services and procedures that have been
// registered with this Dispatcher.
func (d *Dispatcher) Procedures() []transport.Procedure {
return d.table.Procedures()
}

// Choose picks a handler for the given request or returns an error if a
// handler for this request does not exist.
func (d *Dispatcher) Choose(ctx context.Context, req *transport.Request) (transport.HandlerSpec, error) {
return d.table.Choose(ctx, req)
}

// Register configures the dispatcher's router to route inbound requests to a
// collection of procedure handlers.
func (d *Dispatcher) Register(rs []transport.Procedure) {
Expand Down Expand Up @@ -297,7 +284,7 @@ func (d *Dispatcher) Start() error {
// Start Inbounds
wait = intsync.ErrorWaiter{}
for _, i := range d.inbounds {
i.SetRouter(d)
i.SetRouter(d.table)
wait.Submit(start(i))
}
if errs := wait.Wait(); len(errs) != 0 {
Expand Down
3 changes: 1 addition & 2 deletions internal/crossdock/server/yarpc/server.go
Expand Up @@ -24,7 +24,6 @@ import (
"fmt"

"go.uber.org/yarpc"
"go.uber.org/yarpc/api/transport"
"go.uber.org/yarpc/encoding/json"
"go.uber.org/yarpc/encoding/raw"
"go.uber.org/yarpc/internal/crossdock/thrift/echo/yarpc/echoserver"
Expand Down Expand Up @@ -68,7 +67,7 @@ func Stop() {
}
}

func register(reg transport.RouteTable) {
func register(reg *yarpc.Dispatcher) {
reg.Register(raw.Procedure("echo/raw", EchoRaw))
reg.Register(json.Procedure("echo", EchoJSON))

Expand Down

0 comments on commit 0e506a5

Please sign in to comment.