Code Monkey home page Code Monkey logo

Comments (11)

funny-falcon avatar funny-falcon commented on September 28, 2024 1

Sorry, will try to do this week.

from go-tarantool.

funny-falcon avatar funny-falcon commented on September 28, 2024 1

Я говорю о чтении самой очереди, меня смутило, что необходимо проверять после Take сам таск на nil в бесконечном цикле для поддержания постоянного чтения очереди.

Пусть не смущает. Если есть мысль, как "улучшить", я готов рассмотреть пул реквест.

Начал тестировать и пока не могу понять почему не работает Delay, правильно я понимаю, что это возможность отложить получение таска воркером?

Скорее всего, да. Я сам очередями не пользовался, так что мне трудно сказать. Посмотри здесь: https://github.com/tarantool/queue , и попробуй.

from go-tarantool.

funny-falcon avatar funny-falcon commented on September 28, 2024

If you describe desired interface, then it could happen.
(note: do not put much magic in, please).

from go-tarantool.

FireGM avatar FireGM commented on September 28, 2024
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.

nkschmidt avatar nkschmidt commented on September 28, 2024

Hi. What about this?

from go-tarantool.

funny-falcon avatar funny-falcon commented on September 28, 2024

Interface for queue were merged. Could I close this issue? or you have some additional thoughts on.

from go-tarantool.

nkschmidt avatar nkschmidt commented on September 28, 2024

Правильно я понимаю, что чтобы реализовать постоянное чтение из очереди, нужно 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.

funny-falcon avatar funny-falcon commented on September 28, 2024

Запрос с бесконечным таймаутом? это, мне кажется, проблематично.
Не знаю, как со стороны очереди, но со стороны драйвера это сейчас точно проблематично.

Как вариант, можно сделать обёртку, которая на nil сама делает retry.

Ещё вариант, создать коннект без таймаута, очередь без таймаута, и q.Take() - это будет похоже на то, что ты предлагаешь?
Если нет, то как твой итератор должен работать в присутствии таймаутов?

from go-tarantool.

nkschmidt avatar nkschmidt commented on September 28, 2024

Мне кажется мы не совсем поняли друг друга.
Я говорю о чтении самой очереди, меня смутило, что необходимо проверять после Take сам таск на nil в бесконечном цикле для поддержания постоянного чтения очереди.

Начал тестировать и пока не могу понять почему не работает Delay, правильно я понимаю, что это возможность отложить получение таска воркером?

from go-tarantool.

nkschmidt avatar nkschmidt commented on September 28, 2024

Ок.
По delay кажется понял в чем проблема, нужно указывать другой тип очереди.
В любом случае спасибо за реализованную поддержку очередей.

from go-tarantool.

funny-falcon avatar funny-falcon commented on September 28, 2024

Ну, спасибо по большей части не мне. Я только замержил и дошлифовал.

Я понимаю, что можно закрыть тикет. Не стесняйся открывать новые, ок?

from go-tarantool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.