surrealpatch/mem/mem.go
Tobie Morgan Hitchcock d5604f589c Add package for memory storage of database runtime
Database configuration data for all namespaces, databases, logins, tokens, scopes, tables, fields, indexes should be stored in memory for quick access when needed without querying the KV store.

It should be kept in sync with the master data in the unerlying KV store, but it can be used for propagating the database configuration across the cluster.
2016-11-21 18:47:23 +00:00

90 lines
1.5 KiB
Go

// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package mem
import (
"time"
"github.com/abcum/surreal/sql"
)
var store map[string]*NS
type NS struct {
AC map[string]*AC
TK map[string]*TK
DB map[string]*DB
Name string
}
type DB struct {
AC map[string]*AC
TK map[string]*TK
SC map[string]*SC
TB map[string]*TB
Name string
}
type TB struct {
FD map[string]*FD
IX map[string]*IX
Name string
}
type AC struct {
User string
Pass string
Uniq string
}
type TK struct {
Name string
Type string
Text string
}
type SC struct {
TK map[string]*TK
Name string
Uniq string
Time time.Duration
Signup sql.Expr
Signin sql.Expr
}
type FD struct {
Name string
Type string
Enum []interface{}
Code string
Min float64
Max float64
Match string
Default interface{}
Notnull bool
Readonly bool
Mandatory bool
Validate bool
}
type IX struct {
Name string
Cols []string
Uniq bool
}
func init() {
store = make(map[string]*NS)
}