| 231 | } |
| 232 | |
| 233 | func Create(ctx context.Context, engine storage.Engine, path *storage.URI, base ID) (*Queue, error) { |
| 234 | q := New(engine, path) |
| 235 | if err := q.writeHead(ctx, Nil); err != nil { |
| 236 | return nil, err |
| 237 | } |
| 238 | // Tail is initialized with the first entry of the journal, which does |
| 239 | // not yet exist. The journal is empty iff HEAD == 0. Once written |
| 240 | // to the journal is never empty again, but it may be reset by higher |
| 241 | // layers by writing a NOP and moving TAIL to HEAD. |
| 242 | if err := q.writeTail(ctx, 1, base); err != nil { |
| 243 | return nil, err |
| 244 | } |
| 245 | return q, nil |
| 246 | } |
| 247 | |
| 248 | func Open(ctx context.Context, engine storage.Engine, path *storage.URI) (*Queue, error) { |
| 249 | q := New(engine, path) |