Merge pull request #27 from anyproto/change-add-to-tryadd-streampool

This commit is contained in:
Mikhail Rakhmanov 2023-06-19 11:14:52 +02:00 committed by GitHub
commit fe7b97bee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package synctree
import ( import (
"context" "context"
"github.com/anyproto/any-sync/app/logger" "github.com/anyproto/any-sync/app/logger"
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree" "github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto" "github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"

View File

@ -2,11 +2,12 @@ package streampool
import ( import (
"context" "context"
"sync/atomic"
"github.com/anyproto/any-sync/app/logger" "github.com/anyproto/any-sync/app/logger"
"github.com/cheggaaa/mb/v3" "github.com/cheggaaa/mb/v3"
"go.uber.org/zap" "go.uber.org/zap"
"storj.io/drpc" "storj.io/drpc"
"sync/atomic"
) )
type stream struct { type stream struct {
@ -22,7 +23,7 @@ type stream struct {
} }
func (sr *stream) write(msg drpc.Message) (err error) { func (sr *stream) write(msg drpc.Message) (err error) {
return sr.queue.Add(sr.stream.Context(), msg) return sr.queue.TryAdd(msg)
} }
func (sr *stream) readLoop() error { func (sr *stream) readLoop() error {

View File

@ -2,18 +2,19 @@ package streampool
import ( import (
"fmt" "fmt"
"sort"
"sync"
"sync/atomic"
"testing"
"time"
"github.com/anyproto/any-sync/net/peer" "github.com/anyproto/any-sync/net/peer"
"github.com/anyproto/any-sync/net/rpc/rpctest" "github.com/anyproto/any-sync/net/rpc/rpctest"
"github.com/anyproto/any-sync/net/streampool/testservice" "github.com/anyproto/any-sync/net/streampool/testservice"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context" "golang.org/x/net/context"
"sort"
"storj.io/drpc" "storj.io/drpc"
"sync"
"sync/atomic"
"testing"
"time"
) )
var ctx = context.Background() var ctx = context.Background()