@@ -35,26 +35,26 @@ func (v *View) Definition() Node {
35
35
36
36
// Views are scoped by the databases in which they were defined, so a key in
37
37
// the view registry is a pair of names: database and view.
38
- type viewKey struct {
38
+ type ViewKey struct {
39
39
dbName , viewName string
40
40
}
41
41
42
- // newViewKey creates a viewKey ensuring both names are lowercase.
43
- func newViewKey (databaseName , viewName string ) viewKey {
44
- return viewKey {strings .ToLower (databaseName ), strings .ToLower (viewName )}
42
+ // NewViewKey creates a ViewKey ensuring both names are lowercase.
43
+ func NewViewKey (databaseName , viewName string ) ViewKey {
44
+ return ViewKey {strings .ToLower (databaseName ), strings .ToLower (viewName )}
45
45
}
46
46
47
- // ViewRegistry is a map of viewKey to View whose access is protected by a
47
+ // ViewRegistry is a map of ViewKey to View whose access is protected by a
48
48
// RWMutex.
49
49
type ViewRegistry struct {
50
50
mutex sync.RWMutex
51
- views map [viewKey ]View
51
+ views map [ViewKey ]View
52
52
}
53
53
54
54
// NewViewRegistry creates an empty ViewRegistry.
55
55
func NewViewRegistry () * ViewRegistry {
56
56
return & ViewRegistry {
57
- views : make (map [viewKey ]View ),
57
+ views : make (map [ViewKey ]View ),
58
58
}
59
59
}
60
60
@@ -64,7 +64,7 @@ func (r *ViewRegistry) Register(database string, view View) error {
64
64
r .mutex .Lock ()
65
65
defer r .mutex .Unlock ()
66
66
67
- key := newViewKey (database , view .Name ())
67
+ key := NewViewKey (database , view .Name ())
68
68
69
69
if _ , ok := r .views [key ]; ok {
70
70
return ErrExistingView .New (database , view .Name ())
@@ -80,7 +80,7 @@ func (r *ViewRegistry) Delete(databaseName, viewName string) error {
80
80
r .mutex .Lock ()
81
81
defer r .mutex .Unlock ()
82
82
83
- key := newViewKey (databaseName , viewName )
83
+ key := NewViewKey (databaseName , viewName )
84
84
85
85
if _ , ok := r .views [key ]; ! ok {
86
86
return ErrNonExistingView .New (databaseName , viewName )
@@ -96,7 +96,7 @@ func (r *ViewRegistry) View(databaseName, viewName string) (*View, error) {
96
96
r .mutex .RLock ()
97
97
defer r .mutex .RUnlock ()
98
98
99
- key := newViewKey (databaseName , viewName )
99
+ key := NewViewKey (databaseName , viewName )
100
100
101
101
if view , ok := r .views [key ]; ok {
102
102
return & view , nil
@@ -106,7 +106,7 @@ func (r *ViewRegistry) View(databaseName, viewName string) (*View, error) {
106
106
}
107
107
108
108
// AllViews returns the map of all views in the registry.
109
- func (r * ViewRegistry ) AllViews () map [viewKey ]View {
109
+ func (r * ViewRegistry ) AllViews () map [ViewKey ]View {
110
110
r .mutex .RLock ()
111
111
defer r .mutex .RUnlock ()
112
112
0 commit comments