pubsub scales linearly with clients, so 2 pub=13ps and 4 sub=17ps
parent
959e326329
commit
90a3256b7b
|
|
@ -221,23 +221,23 @@ func run(ctx context.Context) error {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
go with.Every(ctx, 1, func() {
|
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
topic := fmt.Sprintf("topic_%d", i)
|
topic := fmt.Sprintf("topic_%d", i)
|
||||||
|
go with.Every(ctx, 1, func() {
|
||||||
if err := pub(topic, 1); err != nil {
|
if err := pub(topic, 1); err != nil {
|
||||||
log.Printf("failed pub: %v", err)
|
log.Printf("failed pub: %v", err)
|
||||||
} else {
|
} else {
|
||||||
pubs.Add(1)
|
pubs.Add(1)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
with.Every(ctx, 1, func() {
|
|
||||||
if err := func() error {
|
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
topic := fmt.Sprintf("topic_%d", i)
|
topic := fmt.Sprintf("topic_%d", i)
|
||||||
for j := 0; j < 2; j++ {
|
for j := 0; j < 2; j++ {
|
||||||
group := fmt.Sprintf("group_%d", i)
|
group := fmt.Sprintf("group_%d", i)
|
||||||
|
go with.Every(ctx, 1, func() {
|
||||||
|
if err := func() error {
|
||||||
if partition, offset, _, err := sub(topic, group); err != nil {
|
if partition, offset, _, err := sub(topic, group); err != nil {
|
||||||
return fmt.Errorf("failed sub: %w", err)
|
return fmt.Errorf("failed sub: %w", err)
|
||||||
} else if partition == -1 {
|
} else if partition == -1 {
|
||||||
|
|
@ -247,14 +247,15 @@ func run(ctx context.Context) error {
|
||||||
subs.Add(1)
|
subs.Add(1)
|
||||||
lastCommit = fmt.Sprintf("%s/%s/%d@%d", topic, group, partition, offset)
|
lastCommit = fmt.Sprintf("%s/%s/%d@%d", topic, group, partition, offset)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
log.Printf("failed subs: %v", err)
|
log.Printf("failed subs: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<-ctx.Done()
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue