Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
issue #165: work above ProtectedStorage, Input part
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Sep 5, 2018
1 parent a77c57c commit 9b2e9bd
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/server/grpc/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package grpc

import (
"context"
"github.com/kamilsk/form-api/pkg/domain"

"github.com/kamilsk/form-api/pkg/domain"
"github.com/kamilsk/form-api/pkg/storage/query"
"github.com/kamilsk/form-api/pkg/storage/types"
)
Expand All @@ -19,4 +19,6 @@ type ProtectedStorage interface {
ReadTemplate(context.Context, *types.Token, query.ReadTemplate) (types.Template, error)
UpdateTemplate(context.Context, *types.Token, query.UpdateTemplate) (types.Template, error)
DeleteTemplate(context.Context, *types.Token, query.DeleteTemplate) (types.Template, error)
ReadInputByID(context.Context, *types.Token, domain.ID) (types.Input, error)
ReadInputByFilter(context.Context, *types.Token, query.InputFilter) ([]types.Input, error)
}
26 changes: 26 additions & 0 deletions pkg/server/grpc/mock_storage_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions pkg/storage/protected.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,25 @@ func (storage *Storage) DeleteTemplate(ctx context.Context, token *types.Token,

return storage.exec.TemplateEditor(ctx, conn).Delete(token, data)
}

// ReadInputByID TODO
func (storage *Storage) ReadInputByID(ctx context.Context, token *types.Token, id domain.ID) (types.Input, error) {
conn, closer, err := storage.connection(ctx)
if err != nil {
return types.Input{}, err
}
defer closer()

return storage.exec.InputReader(ctx, conn).ReadByID(token, id)
}

// ReadInputByFilter TODO
func (storage *Storage) ReadInputByFilter(ctx context.Context, token *types.Token, filter query.InputFilter) ([]types.Input, error) {
conn, closer, err := storage.connection(ctx)
if err != nil {
return nil, err
}
defer closer()

return storage.exec.InputReader(ctx, conn).ReadByFilter(token, filter)
}

0 comments on commit 9b2e9bd

Please sign in to comment.