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

fix: add grpc send interval #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion control_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"log"
"os"
"sync"
"time"

"github.com/opensergo/opensergo-control-plane/pkg/controller"
"github.com/opensergo/opensergo-control-plane/pkg/model"
Expand All @@ -26,6 +27,8 @@ import (
"github.com/pkg/errors"
)

const sendInterval = 100 * time.Millisecond

type ControlPlane struct {
operator *controller.KubernetesOperator
server *transport.Server
Expand Down Expand Up @@ -94,7 +97,7 @@ func (c *ControlPlane) sendMessageToStream(stream model.OpenSergoTransportStream
if stream == nil {
return nil
}
return stream.SendMsg(&trpb.SubscribeResponse{
err := stream.SendMsg(&trpb.SubscribeResponse{
Status: status,
Ack: "",
Namespace: namespace,
Expand All @@ -104,6 +107,11 @@ func (c *ControlPlane) sendMessageToStream(stream model.OpenSergoTransportStream
ControlPlane: c.protoDesc,
ResponseId: respId,
})
if err != nil {
return err
}
time.Sleep(sendInterval)
return nil
}

func (c *ControlPlane) handleSubscribeRequest(clientIdentifier model.ClientIdentifier, request *trpb.SubscribeRequest, stream model.OpenSergoTransportStream) error {
Expand Down