mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
chore: fix typo
This commit is contained in:
parent
721b7def7c
commit
4bdf5e4c90
@ -34,7 +34,7 @@ func TestContextCancel(t *testing.T) {
|
|||||||
assert.NotEqual(t, context.Canceled, c2.Err())
|
assert.NotEqual(t, context.Canceled, c2.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConextDeadline(t *testing.T) {
|
func TestContextDeadline(t *testing.T) {
|
||||||
c, _ := context.WithDeadline(context.Background(), time.Now().Add(10*time.Millisecond))
|
c, _ := context.WithDeadline(context.Background(), time.Now().Add(10*time.Millisecond))
|
||||||
o := ValueOnlyFrom(c)
|
o := ValueOnlyFrom(c)
|
||||||
select {
|
select {
|
||||||
|
@ -12,14 +12,14 @@ func TestBulkExecutor(t *testing.T) {
|
|||||||
var values []int
|
var values []int
|
||||||
var lock sync.Mutex
|
var lock sync.Mutex
|
||||||
|
|
||||||
exeutor := NewBulkExecutor(func(items []interface{}) {
|
executor := NewBulkExecutor(func(items []interface{}) {
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
values = append(values, len(items))
|
values = append(values, len(items))
|
||||||
lock.Unlock()
|
lock.Unlock()
|
||||||
}, WithBulkTasks(10), WithBulkInterval(time.Minute))
|
}, WithBulkTasks(10), WithBulkInterval(time.Minute))
|
||||||
|
|
||||||
for i := 0; i < 50; i++ {
|
for i := 0; i < 50; i++ {
|
||||||
exeutor.Add(1)
|
executor.Add(1)
|
||||||
time.Sleep(time.Millisecond)
|
time.Sleep(time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,13 +40,13 @@ func TestBulkExecutorFlushInterval(t *testing.T) {
|
|||||||
var wait sync.WaitGroup
|
var wait sync.WaitGroup
|
||||||
|
|
||||||
wait.Add(1)
|
wait.Add(1)
|
||||||
exeutor := NewBulkExecutor(func(items []interface{}) {
|
executor := NewBulkExecutor(func(items []interface{}) {
|
||||||
assert.Equal(t, size, len(items))
|
assert.Equal(t, size, len(items))
|
||||||
wait.Done()
|
wait.Done()
|
||||||
}, WithBulkTasks(caches), WithBulkInterval(time.Millisecond*100))
|
}, WithBulkTasks(caches), WithBulkInterval(time.Millisecond*100))
|
||||||
|
|
||||||
for i := 0; i < size; i++ {
|
for i := 0; i < size; i++ {
|
||||||
exeutor.Add(1)
|
executor.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
wait.Wait()
|
wait.Wait()
|
||||||
|
@ -12,14 +12,14 @@ func TestChunkExecutor(t *testing.T) {
|
|||||||
var values []int
|
var values []int
|
||||||
var lock sync.Mutex
|
var lock sync.Mutex
|
||||||
|
|
||||||
exeutor := NewChunkExecutor(func(items []interface{}) {
|
executor := NewChunkExecutor(func(items []interface{}) {
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
values = append(values, len(items))
|
values = append(values, len(items))
|
||||||
lock.Unlock()
|
lock.Unlock()
|
||||||
}, WithChunkBytes(10), WithFlushInterval(time.Minute))
|
}, WithChunkBytes(10), WithFlushInterval(time.Minute))
|
||||||
|
|
||||||
for i := 0; i < 50; i++ {
|
for i := 0; i < 50; i++ {
|
||||||
exeutor.Add(1, 1)
|
executor.Add(1, 1)
|
||||||
time.Sleep(time.Millisecond)
|
time.Sleep(time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,13 +40,13 @@ func TestChunkExecutorFlushInterval(t *testing.T) {
|
|||||||
var wait sync.WaitGroup
|
var wait sync.WaitGroup
|
||||||
|
|
||||||
wait.Add(1)
|
wait.Add(1)
|
||||||
exeutor := NewChunkExecutor(func(items []interface{}) {
|
executor := NewChunkExecutor(func(items []interface{}) {
|
||||||
assert.Equal(t, size, len(items))
|
assert.Equal(t, size, len(items))
|
||||||
wait.Done()
|
wait.Done()
|
||||||
}, WithChunkBytes(caches), WithFlushInterval(time.Millisecond*100))
|
}, WithChunkBytes(caches), WithFlushInterval(time.Millisecond*100))
|
||||||
|
|
||||||
for i := 0; i < size; i++ {
|
for i := 0; i < size; i++ {
|
||||||
exeutor.Add(1, 1)
|
executor.Add(1, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
wait.Wait()
|
wait.Wait()
|
||||||
|
@ -49,7 +49,7 @@ func From(generate GenerateFunc) Stream {
|
|||||||
return Range(source)
|
return Range(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just converts the given arbitary items to a Stream.
|
// Just converts the given arbitrary items to a Stream.
|
||||||
func Just(items ...interface{}) Stream {
|
func Just(items ...interface{}) Stream {
|
||||||
source := make(chan interface{}, len(items))
|
source := make(chan interface{}, len(items))
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
@ -195,7 +195,7 @@ func (p Stream) Merge() Stream {
|
|||||||
return Range(source)
|
return Range(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parallel applies the given ParallenFunc to each item concurrently with given number of workers.
|
// Parallel applies the given ParallelFunc to each item concurrently with given number of workers.
|
||||||
func (p Stream) Parallel(fn ParallelFunc, opts ...Option) {
|
func (p Stream) Parallel(fn ParallelFunc, opts ...Option) {
|
||||||
p.Walk(func(item interface{}, pipe chan<- interface{}) {
|
p.Walk(func(item interface{}, pipe chan<- interface{}) {
|
||||||
fn(item)
|
fn(item)
|
||||||
|
@ -8,11 +8,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
exeutor := executors.NewBulkExecutor(func(items []interface{}) {
|
executor := executors.NewBulkExecutor(func(items []interface{}) {
|
||||||
fmt.Println(len(items))
|
fmt.Println(len(items))
|
||||||
}, executors.WithBulkTasks(10))
|
}, executors.WithBulkTasks(10))
|
||||||
for {
|
for {
|
||||||
exeutor.Add(1)
|
executor.Add(1)
|
||||||
time.Sleep(time.Millisecond * 90)
|
time.Sleep(time.Millisecond * 90)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user