Comments (11)
Sorry, will try to do this week.
from go-tarantool.
Я говорю о чтении самой очереди, меня смутило, что необходимо проверять после Take сам таск на nil в бесконечном цикле для поддержания постоянного чтения очереди.
Пусть не смущает. Если есть мысль, как "улучшить", я готов рассмотреть пул реквест.
Начал тестировать и пока не могу понять почему не работает Delay, правильно я понимаю, что это возможность отложить получение таска воркером?
Скорее всего, да. Я сам очередями не пользовался, так что мне трудно сказать. Посмотри здесь: https://github.com/tarantool/queue , и попробуй.
from go-tarantool.
If you describe desired interface, then it could happen.
(note: do not put much magic in, please).
from go-tarantool.
type Queue interface {
GetTube(name string) (*Tube, error)
NewTube(name string, ttl int, delay int) (*Tube, error)
DeleteTube(name string) (error)
}
type Tube interface {
Next() (TubeData, error)
Put(data string) (*Tube, error) //[]byte?
}
type TubeData interface {
GetId() int
Ack() error
Release() error
Delete() error
GetData() string //[]byte?
}
func main() {
client, _ := tarantool.Connect(server, opts)
tube := client.Queue.GetTube("my_tube").(Tube)
go func() {
for i := 0; i < 10; i++ {
tube.Put("new_data")
}
}()
for {
td, err := tube.Next()
if err != nil {
break
}
fmt.Println(td.GetData()) // new_data
td.Ack()
}
}
from go-tarantool.
Hi. What about this?
from go-tarantool.
Interface for queue were merged. Could I close this issue? or you have some additional thoughts on.
from go-tarantool.
Правильно я понимаю, что чтобы реализовать постоянное чтение из очереди, нужно task проверять на nil ?
go func() {
for {
task, err := q.TakeTimeout(1 * time.Second)
if err != nil {
fmt.Printf("error in take with is %v", err)
continue
}
if task == nil {
continue
}
fmt.Println("data_1: ", task.Data())
task.Ack()
}
}
Я к тому, что не логичней было бы добавить iterator, в варианте выше?
from go-tarantool.
Запрос с бесконечным таймаутом? это, мне кажется, проблематично.
Не знаю, как со стороны очереди, но со стороны драйвера это сейчас точно проблематично.
Как вариант, можно сделать обёртку, которая на nil сама делает retry.
Ещё вариант, создать коннект без таймаута, очередь без таймаута, и q.Take() - это будет похоже на то, что ты предлагаешь?
Если нет, то как твой итератор должен работать в присутствии таймаутов?
from go-tarantool.
Мне кажется мы не совсем поняли друг друга.
Я говорю о чтении самой очереди, меня смутило, что необходимо проверять после Take сам таск на nil в бесконечном цикле для поддержания постоянного чтения очереди.
Начал тестировать и пока не могу понять почему не работает Delay, правильно я понимаю, что это возможность отложить получение таска воркером?
from go-tarantool.
Ок.
По delay кажется понял в чем проблема, нужно указывать другой тип очереди.
В любом случае спасибо за реализованную поддержку очередей.
from go-tarantool.
Ну, спасибо по большей части не мне. Я только замержил и дошлифовал.
Я понимаю, что можно закрыть тикет. Не стесняйся открывать новые, ок?
from go-tarantool.
Related Issues (20)
- v2: broken build with `-tags go_tarantool_ssl_disable`
- Suddenly go-openssl broken for go-tarantool HOT 1
- Support IPROTO_TUPLE_FORMATS
- ci: bad file descriptor for Tarantool
- crud: typed batches HOT 2
- Support IPROTO_IS_SYNC
- Cant GetTyped if one of tarantool response keys is non-string typed HOT 4
- pool: improve pool.Connect logic
- pool: add abiliry to make a request by an instance name
- gomod: bump go to 1.20
- pool: get status of an instance via WATCH_ONCE
- Update the code to go 1.20
- go-tarantool/v2/pool.Add: no logs on single connection failure HOT 2
- Can't get space length via tarantool.crud HOT 4
- Replace no longer works as expected on v2? HOT 1
- Integer/Unsigned number no longer valid since 3.x+v2? HOT 5
- api: add support of a batch insert request
- Add balancing strategies interface
- ci: remove macos-11
- api: add a constant for "concurrent schema update"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-tarantool.