Skip to content

Commit

Permalink
remove all heartbeats
Browse files Browse the repository at this point in the history
  • Loading branch information
ingon committed Jan 18, 2025
1 parent dd23312 commit 35fceb2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 147 deletions.
38 changes: 0 additions & 38 deletions client/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ func (d *Destination) runDestinationErr(ctx context.Context, stream quic.Stream)
switch {
case req.Connect != nil:
return d.runConnect(ctx, stream)
case req.Heartbeat != nil:
return d.heartbeat(ctx, stream, req.Heartbeat)
default:
err := pb.NewError(pb.Error_RequestUnknown, "unknown request: %v", req)
if err := pb.Write(stream, &pbc.Response{Error: err}); err != nil {
Expand Down Expand Up @@ -187,42 +185,6 @@ func (d *Destination) runConnect(ctx context.Context, stream quic.Stream) error
return nil
}

func (d *Destination) heartbeat(ctx context.Context, stream quic.Stream, hbt *pbc.Heartbeat) error {
if err := pb.Write(stream, &pbc.Response{Heartbeat: hbt}); err != nil {
return err
}

g, ctx := errgroup.WithContext(ctx)

g.Go(func() error {
<-ctx.Done()
stream.CancelRead(0)
return nil
})

g.Go(func() error {
for {
req, err := pbc.ReadRequest(stream)
if err != nil {
return err
}
if req.Heartbeat == nil {
respErr := pb.NewError(pb.Error_RequestUnknown, "unexpected request")
if err := pb.Write(stream, &pbc.Response{Error: respErr}); err != nil {
return kleverr.Ret(err)
}
return respErr
}

if err := pb.Write(stream, &pbc.Response{Heartbeat: req.Heartbeat}); err != nil {
return err
}
}
})

return g.Wait()
}

func (d *Destination) RunControl(ctx context.Context, conn quic.Connection) error {
return (&peerControl{
local: d.peer,
Expand Down
124 changes: 23 additions & 101 deletions pbc/client.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions pbc/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@ syntax = "proto3";
package client;

import "shared.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/connet-dev/connet/pbc";

message Request {
// Soft one-of
Connect connect = 1;
Heartbeat heartbeat = 2;

message Connect {
}
}

message Response {
shared.Error error = 1;

Heartbeat heartbeat = 2;
}

message Heartbeat {
google.protobuf.Timestamp time = 1;
}

0 comments on commit 35fceb2

Please sign in to comment.