File tree Expand file tree Collapse file tree 4 files changed +55
-6
lines changed
Expand file tree Collapse file tree 4 files changed +55
-6
lines changed Original file line number Diff line number Diff line change 1+ package filter
2+
3+ var processorInstance Processor
4+
5+ func SetProcessor (processor Processor ) {
6+ processorInstance = processor
7+ }
8+
9+ func GetProcessor () Processor {
10+ if processorInstance == nil {
11+ panic ("filter processor is nil" )
12+ }
13+
14+ return processorInstance
15+ }
Original file line number Diff line number Diff line change 1+ package filter
2+
3+ import (
4+ "encoding/json"
5+ )
6+
7+ type Processor interface {
8+ // Check if a filter exists
9+ FilterExists (filter string ) bool
10+
11+ // Create a new instance of the filter
12+ CreateFilter (filter string ) interface {}
13+
14+ // Validate structure for filter validness
15+ ValidateFilter (filter ProcessedFilter ) (bool , error )
16+ }
17+
18+ type EncodedFilter struct {
19+ Type string `json:"type"`
20+ Data json.RawMessage `json:"data"`
21+ }
22+
23+ type ProcessedFilter struct {
24+ Type string `json:"type"`
25+ Data interface {} `json:"data"`
26+ }
Original file line number Diff line number Diff line change 11package plugins
22
3+ import (
4+ "github.com/StratoAPI/Interface/filter"
5+ )
6+
37type Plugin interface {
48 // The name of the plugin
59 Name () string
@@ -30,16 +34,16 @@ type Storage interface {
3034 Stop () error
3135
3236 // Retrieve resources.
33- GetResources (resource string , filters []interface {} ) ([]map [string ]interface {}, error )
37+ GetResources (resource string , filters []filter. ProcessedFilter ) ([]map [string ]interface {}, error )
3438
3539 // Create resources.
3640 CreateResources (resource string , data []map [string ]interface {}) error
3741
3842 // Update resources.
39- UpdateResources (resource string , data []map [string ]interface {}, filters []interface {} ) error
43+ UpdateResources (resource string , data []map [string ]interface {}, filters []filter. ProcessedFilter ) error
4044
4145 // Delete resources.
42- DeleteResources (resource string , filters []interface {} ) error
46+ DeleteResources (resource string , filters []filter. ProcessedFilter ) error
4347}
4448
4549type Filter interface {
@@ -53,7 +57,10 @@ type Filter interface {
5357 Stop () error
5458
5559 // Validate structure for filter validness
56- ValidateFilter (filter interface {}) (bool , error )
60+ ValidateFilter (filter filter.ProcessedFilter ) (bool , error )
61+
62+ // Create a new instance of the filter
63+ CreateFilter (filter string ) interface {}
5764}
5865
5966type Registry interface {
Original file line number Diff line number Diff line change 11package schema
22
33type Processor interface {
4- // Get the store of a resource
4+ // Check if a resource schema exists
55 ResourceExists (resource string ) bool
66
7- // Get a list of all resources
7+ // Check if the resource structure is valid
88 ResourceValid (resource string , data string ) (bool , error )
99
10+ // Get the schema of a resource
1011 GetSchema (resource string ) * Schema
1112}
1213
You can’t perform that action at this time.
0 commit comments