| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package memory | 5 package memory |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "sync" | 9 "sync" |
| 10 "time" | 10 "time" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 var _ storage.Storage = (*Storage)(nil) | 50 var _ storage.Storage = (*Storage)(nil) |
| 51 | 51 |
| 52 // Close implements storage.Storage. | 52 // Close implements storage.Storage. |
| 53 func (s *Storage) Close() { | 53 func (s *Storage) Close() { |
| 54 s.run(func() error { | 54 s.run(func() error { |
| 55 s.closed = true | 55 s.closed = true |
| 56 return nil | 56 return nil |
| 57 }) | 57 }) |
| 58 } | 58 } |
| 59 | 59 |
| 60 // ResetClose resets the storage instance, allowing it to be used another time. |
| 61 // The data stored in this instance is not changed. |
| 62 func (s *Storage) ResetClose() { |
| 63 s.stateMu.Lock() |
| 64 defer s.stateMu.Unlock() |
| 65 |
| 66 s.closed = false |
| 67 } |
| 68 |
| 60 // Config implements storage.Storage. | 69 // Config implements storage.Storage. |
| 61 func (s *Storage) Config(cfg storage.Config) error { | 70 func (s *Storage) Config(cfg storage.Config) error { |
| 62 return s.run(func() error { | 71 return s.run(func() error { |
| 63 s.MaxLogAge = cfg.MaxLogAge | 72 s.MaxLogAge = cfg.MaxLogAge |
| 64 return nil | 73 return nil |
| 65 }) | 74 }) |
| 66 } | 75 } |
| 67 | 76 |
| 68 // Put implements storage.Storage. | 77 // Put implements storage.Storage. |
| 69 func (s *Storage) Put(req storage.PutRequest) error { | 78 func (s *Storage) Put(req storage.PutRequest) error { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 218 } |
| 210 | 219 |
| 211 if s.streams == nil { | 220 if s.streams == nil { |
| 212 s.streams = map[streamKey]*logStream{} | 221 s.streams = map[streamKey]*logStream{} |
| 213 } | 222 } |
| 214 s.streams[key] = ls | 223 s.streams[key] = ls |
| 215 } | 224 } |
| 216 | 225 |
| 217 return ls | 226 return ls |
| 218 } | 227 } |
| OLD | NEW |