Comments (3)
I was thinking something along the lines -
q := NewQueue()
(q *Queue) NewConsumer() (*Consumer, error)
(q *Queue) NewProducer() (*Producer, error)
(q *Queue) Close() error
(c *Consumer) Peek() ([]byte, error)
(c *Consumer) PeekString() (string, error)
(c *Consumer) Dequeue() error
(c *Consumer) PeekAndDequeue() error
(p *Producer) Enqueue(b []byte) error
(p *Producer) EnqeueuString(s string) error
type Policy struct {
block bool
timeout time.Duration
}
from bigqueue.
This is the final API -
- We can have only one producer, which can be shared across multiple routines.
- Multiple consumers are allowed and can read from different offsets simultaneously.
NewQueue(dir string, opts ...Option)
IsEmpty() bool
Flush() error
Close() error
(q *Queue) Enqueue(b []byte) error
(q *Queue) EnqueueString(s string) error
(q *Queue) NewConsumer(name string, opts ...ConsumerOption) (*Consumer, error)
(c *Consumer) Dequeue() error
(c *Consumer) DequeueString() error
from bigqueue.
Data Formats
Metadata File
Head points to the first non-deleted entry in the queue.
Tail points to the last written entry +1 in the queue
Bytes | Data |
---|---|
0-7 | version Number |
8-15 | head arena id |
16-23 | head byte offset in arena |
24-31 | tail arena id |
32-39 | tail byte offset in arena |
40-47 | arena size |
48-55 | number of consumers |
repeated | |
56-63 | length of consumer name (L) |
64-71 | arena id (head) of consumer |
72-79 | byte offset in the arena (head) of consumer |
80-(L+79) | consumer name |
Index File
Bytes | Data |
---|---|
repeated | |
0-7 | arena id |
8-15 | position of first element in the queue |
16-23 | first element byte offset in the arena |
Arena File
Bytes | Data |
---|---|
n - (n+7) | length of element |
(n+8) - (n+7+L) | element of size L |
from bigqueue.
Related Issues (20)
- Why mmap? HOT 2
- Document thread-safety
- Allow calls to be blocked on empty queue
- Allow single writer and multiple reader processes
- Integrate with codefactor, codeclimate, codacy
- Add PeekAndDequeue function and update external sort example HOT 4
- Build a queue lock
- Add policy to decide when to delete old data
- bigqueue panics when benchmarks are run HOT 1
- EnsureArena should avoid iterating from tail to head, this slows down `Dequeue`
- Use slice instead of map to store all arenas, map slows down iteration
- Write multicore benchmark and Improve performance HOT 1
- Handle fsync errors better
- Why no Len() uint64 method for bigqueue? HOT 1
- Update benchmarks
- Release 0.5.0 HOT 1
- Refactoring and new functionality
- Concurrent requests/reply IPC HOT 2
- Limit memory size not available HOT 2
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 bigqueue.