| Put(id string, update StatusMsg) error |
| Get(id string) (*StatusMsg, error) |
| List() ([]StatusMsg, error) |
| func NewStorage(spec string) (Storage, error) { |
| conn, err := url.Parse(spec) |
| switch strings.ToUpper(conn.Scheme) { |
| return NewMemoryStorage(), nil |
| return NewConsulStorage(spec) |
| return nil, fmt.Errorf("Unknown storage scheme specified, '%s'", conn.Scheme) |
| type MemoryStorage struct { |
| Data map[string]StatusMsg |
| func NewMemoryStorage() *MemoryStorage { |
| Data: make(map[string]StatusMsg), |
| func (s *MemoryStorage) Put(id string, update StatusMsg) error { |
| func (s *MemoryStorage) Get(id string) (*StatusMsg, error) { |
| func (s *MemoryStorage) Delete(id string) error { |
| func (s *MemoryStorage) List() ([]StatusMsg, error) { |
| r := make([]StatusMsg, len(s.Data)) |
| for _, v := range s.Data { |