Skip to content
Snippets Groups Projects
Commit 05b30353 authored by gjahn's avatar gjahn
Browse files

cosmetics: e.a. rename store.Show to store.List

* remove some spaces
* return item.Name() instead of map key
* re-order router log output
parent 2f169d3f
No related branches found
No related tags found
No related merge requests found
......@@ -205,15 +205,15 @@ func SetRoutes( router *f.App, config *configuration.Config, store state.Store,
router.Get( "/states", func( c *f.Ctx ) error {
states, err := store.Show()
names, err := store.List()
if err != nil {
return c.SendStatus( http.StatusInternalServerError )
}
const pathPrefix string = "/state"
paths := make ( []string, len( states ) )
for i, state := range states {
paths[ i ] = fmt.Sprintf( "%s/%s", pathPrefix, state )
paths := make( []string, len( names ) )
for i, name := range names {
paths[ i ] = fmt.Sprintf( "%s/%s", pathPrefix, name )
}
headers := c.GetReqHeaders()
......
......@@ -64,15 +64,15 @@ func ( e *Ephemeral ) Fetch( name string ) ( *Item, error ) {
}
func ( e *Ephemeral ) Show() ( []string, error ) {
func ( e *Ephemeral ) List() ( []string, error ) {
if e.store == nil {
return nil, errors.New( "ephemeral storage not available" )
}
e.mux.Lock()
names := make( []string, 0, len( e.store ) )
for k := range e.store {
names = append( names, k )
for _, item := range e.store {
names = append( names, item.Name() )
}
e.mux.Unlock()
......
......@@ -51,8 +51,8 @@ func ( e *Persistent ) Add( i Item ) error {
name := i.Name()
if err := e.client.HSet(
ctx, name,
"data", i.Data(),
"mime", i.MimeType(),
"data", i.Data(),
).Err(); err != nil {
return err
}
......@@ -89,7 +89,7 @@ func ( e *Persistent ) Fetch( name string ) ( *Item, error ) {
}
func ( e *Persistent ) Show() ( []string, error ) {
func ( e *Persistent ) List() ( []string, error ) {
ctx, cancel := context.WithTimeout( context.TODO(), e.timeout )
defer cancel()
......
......@@ -6,7 +6,7 @@ type Store interface {
Add( i Item ) error
Remove( name string ) error
Fetch( name string ) ( *Item, error )
Show() ( []string, error )
List() ( []string, error )
Disconnect() error
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment