(ctx context.Context, head, tail ID)
| 154 | } |
| 155 | |
| 156 | func (q *Queue) Open(ctx context.Context, head, tail ID) (io.Reader, error) { |
| 157 | if head == Nil { |
| 158 | var err error |
| 159 | head, err = q.ReadHead(ctx) |
| 160 | if err != nil { |
| 161 | return nil, err |
| 162 | } |
| 163 | if head == Nil { |
| 164 | // Return an empty reader when the journal is empty. |
| 165 | // This is preferred over returning ErrEmpty and |
| 166 | // havings layers above report the error message instead |
| 167 | // of simply processing an empty input without error. |
| 168 | return strings.NewReader(""), nil |
| 169 | } |
| 170 | } |
| 171 | if tail == Nil { |
| 172 | var err error |
| 173 | tail, _, err = q.ReadTail(ctx) |
| 174 | if err != nil { |
| 175 | return nil, err |
| 176 | } |
| 177 | } |
| 178 | return q.NewReader(ctx, head, tail), nil |
| 179 | } |
| 180 | |
| 181 | func (q *Queue) putTailLockFile(ctx context.Context) error { |
| 182 | return q.engine.PutIfNotExists(ctx, q.tailLockPath, nil) |
no test coverage detected