mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
+1
-1
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user