mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-09 17:45:03 +09:00
WIP queue metrics
This commit is contained in:
parent
88c12436a6
commit
f37064e0d7
31 changed files with 307 additions and 57 deletions
|
@ -11,6 +11,14 @@ type CounterRequest struct {
|
|||
*synctestproto.CounterRequest
|
||||
}
|
||||
|
||||
func (c CounterRequest) MsgSize() uint64 {
|
||||
if c.CounterRequest != nil {
|
||||
return uint64(proto.Size(c.CounterRequest))
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
func (c CounterRequest) Proto() (proto.Message, error) {
|
||||
return c.CounterRequest, nil
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/commonspace/sync/syncdeps"
|
||||
"github.com/anyproto/any-sync/util/multiqueue"
|
||||
)
|
||||
|
||||
type CounterSyncHandler struct {
|
||||
|
@ -31,11 +32,11 @@ func (c *CounterSyncHandler) HandleHeadUpdate(ctx context.Context, headUpdate dr
|
|||
return c.updateHandler.HandleHeadUpdate(ctx, headUpdate)
|
||||
}
|
||||
|
||||
func (c *CounterSyncHandler) TryAddMessage(ctx context.Context, id string, msg drpc.Message, q *mb.MB[drpc.Message]) error {
|
||||
func (c *CounterSyncHandler) TryAddMessage(ctx context.Context, id string, msg multiqueue.Sizeable, q *mb.MB[multiqueue.Sizeable]) error {
|
||||
return q.TryAdd(msg)
|
||||
}
|
||||
|
||||
func (c *CounterSyncHandler) HandleStreamRequest(ctx context.Context, rq syncdeps.Request, send func(resp proto.Message) error) (syncdeps.Request, error) {
|
||||
func (c *CounterSyncHandler) HandleStreamRequest(ctx context.Context, rq syncdeps.Request, updater syncdeps.QueueSizeUpdater, send func(resp proto.Message) error) (syncdeps.Request, error) {
|
||||
return c.requestHandler.HandleStreamRequest(ctx, rq, send)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,22 +6,19 @@ import (
|
|||
|
||||
"storj.io/drpc"
|
||||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/commonspace/sync/syncdeps"
|
||||
"github.com/anyproto/any-sync/commonspace/sync/synctestproto"
|
||||
"github.com/anyproto/any-sync/net/peer"
|
||||
"github.com/anyproto/any-sync/net/rpc/rpctest"
|
||||
"github.com/anyproto/any-sync/net/rpc/server"
|
||||
"github.com/anyproto/any-sync/net/streampool"
|
||||
"github.com/anyproto/any-sync/util/multiqueue"
|
||||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/commonspace/sync/synctestproto"
|
||||
)
|
||||
|
||||
const RpcName = "rpcserver"
|
||||
|
||||
type SyncService interface {
|
||||
app.Component
|
||||
GetQueue(peerId string) *multiqueue.Queue[drpc.Message]
|
||||
HandleMessage(ctx context.Context, peerId string, msg drpc.Message) error
|
||||
HandleStreamRequest(ctx context.Context, req syncdeps.Request, stream drpc.Stream) error
|
||||
QueueRequest(ctx context.Context, rq syncdeps.Request) error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue