refactor: Remove "Opts" abbreviation (#92)

Having a mixture of abbreviations in the codebase reduces
clarity. Although opts is common for options, I'd rather
set a precedent of clarifying verbosity.
This commit is contained in:
Kyle Carberry
2022-01-29 19:27:44 -06:00
committed by GitHub
parent f9e594fbad
commit 3e88f1502a
5 changed files with 26 additions and 26 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ import (
)
// Dial consumes the PeerBroker gRPC connection negotiation stream to produce a WebRTC peered connection.
func Dial(stream proto.DRPCPeerBroker_NegotiateConnectionClient, iceServers []webrtc.ICEServer, opts *peer.ConnOpts) (*peer.Conn, error) {
func Dial(stream proto.DRPCPeerBroker_NegotiateConnectionClient, iceServers []webrtc.ICEServer, opts *peer.ConnOptions) (*peer.Conn, error) {
// Convert WebRTC ICE servers to the protobuf type.
protoIceServers := make([]*proto.WebRTCICEServer, 0, len(iceServers))
for _, iceServer := range iceServers {
+4 -4
View File
@@ -19,7 +19,7 @@ import (
// Listen consumes the transport as the server-side of the PeerBroker dRPC service.
// The Accept function must be serviced, or new connections will hang.
func Listen(transport drpc.Transport, opts *peer.ConnOpts) (*Listener, error) {
func Listen(transport drpc.Transport, opts *peer.ConnOptions) (*Listener, error) {
ctx, cancelFunc := context.WithCancel(context.Background())
listener := &Listener{
connectionChannel: make(chan *peer.Conn),
@@ -30,7 +30,7 @@ func Listen(transport drpc.Transport, opts *peer.ConnOpts) (*Listener, error) {
mux := drpcmux.New()
err := proto.DRPCRegisterPeerBroker(mux, &peerBrokerService{
connOpts: opts,
connOptions: opts,
listener: listener,
})
@@ -99,13 +99,13 @@ func (l *Listener) isClosed() bool {
type peerBrokerService struct {
listener *Listener
connOpts *peer.ConnOpts
connOptions *peer.ConnOptions
}
// NegotiateConnection negotiates a WebRTC connection.
func (b *peerBrokerService) NegotiateConnection(stream proto.DRPCPeerBroker_NegotiateConnectionStream) error {
// Start with no ICE servers. They can be sent by the client if provided.
peerConn, err := peer.Server([]webrtc.ICEServer{}, b.connOpts)
peerConn, err := peer.Server([]webrtc.ICEServer{}, b.connOptions)
if err != nil {
return xerrors.Errorf("create peer connection: %w", err)
}