Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TChannel Constructors Refactor #543

Merged
merged 1 commit into from
Dec 8, 2016
Merged

Conversation

kriskowal
Copy link
Contributor

Based on #542, this change adds tchannel.NewChannelTransport as the new root object for constructing inbounds and outbounds using a wrapped TChannel, and removes the old Inbound/Outbound types.

The name and types deliberately leave open tchannel.NewTransport as a possibility post-1.0, which would not wrap a Channel and consequently be usable with transport.NewOutbound(chooser).

@mention-bot
Copy link

@kriskowal, thanks for your PR! By analyzing the history of the files in this pull request, we identified @abhinav, @breerly and @AlexAPB to be potential reviewers.

@kriskowal kriskowal changed the base branch from remove-with-registry to dev December 7, 2016 23:47
Copy link
Contributor

@willhug willhug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of small things. Looks really good

"go.uber.org/yarpc/transport"
)

type inboundConfig struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used

@@ -1,96 +1,71 @@
// Copyright (c) 2016 Uber Technologies, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need zee licenses!

package tchannel

import (
"context"
"io"

"github.com/uber/tchannel-go"
"go.uber.org/atomic"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import order

if config.name == "" {
err = fmt.Errorf("can't instantiate TChannelChannelTransport without channel or service name option")
} else {
ch, err = tchannel.NewChannel(config.name, &tchannel.ChannelOptions{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is during initialization, should we just panic on errors?

//
// All inbounds must have been assigned a registry to accept inbound requests.
func (t *ChannelTransport) Start() error {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space?

return err
}

t.addr = t.ch.PeerInfo().HostPort
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we extract the t.addr grabbing into a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to consider in a follow-up. This mechanically extracted from the old code.

// channel to make requests to any connected peer.
func (t *ChannelTransport) NewOutbound() *ChannelOutbound {
return &ChannelOutbound{
started: atomic.NewBool(false),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to set these every time, we can initialize started as a atomic.Bool and it will automatically be set to false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roger, changing to value instead of pointer, using the zero value.


serverTChannel := ytchannel.NewChannelTransport(
ytchannel.WithServiceName("server"),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so clean
6kwlyyijyod9h9qxkqetaqjjd

@kriskowal
Copy link
Contributor Author

@willhug addressed, but keeping the panics out, just to be safe.

@kriskowal kriskowal merged commit a834639 into dev Dec 8, 2016

tchannelTransport := tchannel.NewChannelTransport(
tchannel.WithListenAddr(":8082"),
tchannel.WithServiceName("yarpc-test"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we can call for them? I don't love how they have to specify "yarpc-test".

@abhinav abhinav deleted the tchannel-transport-refactor branch December 29, 2016 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants