Code Monkey home page Code Monkey logo

Comments (3)

mangalaman93 avatar mangalaman93 commented on June 15, 2024

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.

mangalaman93 avatar mangalaman93 commented on June 15, 2024

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.

mangalaman93 avatar mangalaman93 commented on June 15, 2024

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)

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.