Documentation ¶
Index ¶
- Constants
- Variables
- func AddToFormatterFuncsMap(s string, f Formatter) error
- func CVL_LEVEL_LOG(level CVLLogLevel, format string, args ...interface{})
- func ConfigFileSyncHandler()
- func Format(fname string, val string) string
- func GetDbId(dbName string) int
- func GetDbPassword(dbName string) string
- func GetDbSeparator(dbName string) string
- func GetDbSock(dbName string) string
- func GetDbTcpAddr(dbName string) string
- func GetDifference(a, b []string) []string
- func GetTableAndKeyFromRedisKey(redisKey, delim string) (string, string)
- func IsTraceAllowed(tracelevel CVLTraceLevel) bool
- func IsTraceSet() bool
- func NewDbClient(dbName string) *redis.Client
- func ReadConfFile() map[string]string
- func SetTrace(on bool)
- func SkipSemanticValidation() bool
- func SkipValidation() bool
- func TRACE_LEVEL_LOG(tracelevel CVLTraceLevel, fmtStr string, args ...interface{})
- func UpdateRedisOptions(opts *redis.Options)
- type CVLLogLevel
- type CVLTraceLevel
- type Formatter
Constants ¶
View Source
const ( INFO = 0 + iota WARNING ERROR FATAL INFO_DEBUG INFO_API INFO_DATA INFO_DETAIL INFO_TRACE INFO_ALL )
View Source
const ( TRACE_MIN = 0 TRACE_MAX = 8 TRACE_CACHE = 1 << TRACE_MIN TRACE_LIBYANG = 1 << 1 TRACE_YPARSER = 1 << 2 TRACE_CREATE = 1 << 3 TRACE_UPDATE = 1 << 4 TRACE_DELETE = 1 << 5 TRACE_SEMANTIC = 1 << 6 TRACE_ONERROR = 1 << 7 TRACE_SYNTAX = 1 << TRACE_MAX )
View Source
const CVL_LOG_FILE = "/tmp/cvl.log"
View Source
const ENV_VAR_SONIC_DB_CONFIG_FILE = "DB_CONFIG_PATH"
View Source
const SONIC_DB_CONFIG_FILE string = "/var/run/redis/sonic-db/database_config.json"
Variables ¶
View Source
var CVL_CFG_FILE string = "/usr/sbin/cvl_cfg.json"
View Source
var CVL_SCHEMA string = "schema/"
View Source
var FILTER_ENTRIES_LUASCRIPT *redis.Script = redis.NewScript(`
--ARGV[1] => Key patterns
--ARGV[2] => Key names separated by '|'
--ARGV[3] => predicate patterns
--ARGV[4] => Fields to return
--ARGV[5] => Count of entries to return
local tableData = {} ; local tbl = {}
local keys = redis.call('KEYS', ARGV[1])
if #keys == 0 then return end
local count = -1
if (ARGV[5] ~= nil and ARGV[5] ~= "") then count=tonumber(ARGV[5]) end
local sepStart = string.find(keys[1], "|")
if sepStart == nil then return ; end
-- Function to load lua predicate code
local function loadPredicateScript(str)
if (str == nil or str == "") then return nil; end
local f, err = loadstring("return function (k,h) " .. str .. " end")
if f then return f(); else return nil;end
end
local keySetNames = {}
ARGV[2]:gsub("([^|]+)",function(c) table.insert(keySetNames, c) end)
local predicate = loadPredicateScript(ARGV[3])
for _, key in ipairs(keys) do
local hash = redis.call('HGETALL', key)
local row = {}; local keySet = {}; local keyVal = {}
local keyOnly = string.sub(key, sepStart+1)
for index = 1, #hash, 2 do
row[hash[index]] = hash[index + 1]
end
--Split key values
keyOnly:gsub("([^|]+)", function(c) table.insert(keyVal, c) end)
for idx = 1, #keySetNames, 1 do
keySet[keySetNames[idx]] = keyVal[idx]
end
if (predicate == nil) or (predicate(keySet, row) == true) then
tbl[keyOnly] = row
end
if (count ~= -1 and #tbl == count) then break end
end
tableData[string.sub(keys[1], 0, sepStart-1)] = tbl
return cjson.encode(tableData)
`)
View Source
var Tracing bool = false
Functions ¶
func AddToFormatterFuncsMap ¶
func CVL_LEVEL_LOG ¶
func CVL_LEVEL_LOG(level CVLLogLevel, format string, args ...interface{})
func ConfigFileSyncHandler ¶
func ConfigFileSyncHandler()
func GetDbSeparator ¶
GetDbSeparator Get DB separator based on given DB name
func GetDifference ¶
GetDifference This will determine items which are missing in a-list if size of b-list is greater missing in b-list if size of a-list is greater missing in a-list if size of a-list, b-list are equal
func GetTableAndKeyFromRedisKey ¶
GetTableAndKeyFromRedisKey This will return tableName and Key from given rediskey. For ex. rediskey = PORTCHANNEL_MEMBER|PortChannel1|Ethernet4 Output will be "PORTCHANNEL_MEMBER" and "PortChannel1|Ethernet4"
func IsTraceAllowed ¶
func IsTraceAllowed(tracelevel CVLTraceLevel) bool
func IsTraceSet ¶
func IsTraceSet() bool
func ReadConfFile ¶
func SkipSemanticValidation ¶
func SkipSemanticValidation() bool
func SkipValidation ¶
func SkipValidation() bool
func TRACE_LEVEL_LOG ¶
func TRACE_LEVEL_LOG(tracelevel CVLTraceLevel, fmtStr string, args ...interface{})
func UpdateRedisOptions ¶
func UpdateRedisOptions(opts *redis.Options)
Types ¶
Click to show internal directories.
Click to hide internal directories.