Documentation ¶
Index ¶
- Constants
- Variables
- func AdjustUrl(s string) string
- func Avg(data []interface{}) float64
- func CertExpire(certs []tls.Certificate) time.Time
- func CheckEntries(list1, list2 []string) bool
- func Color(col, text string) string
- func ColorUrl(rurl string) string
- func ConddbTime(ts string) string
- func DASError(args ...interface{})
- func DASWarning(args ...interface{})
- func DashboardTime(ts string) string
- func EqualLists(list1, list2 []string) bool
- func ErrPropagate(api string)
- func ErrPropagate2Channel(api string, ch chan interface{})
- func Expire(expire int) int64
- func Fetch(httpClient *http.Client, rurl string, args string, out chan<- ResponseType)
- func FetchRucioToken(rurl string) (string, int64, error)
- func FetchRucioTokenViaCurl(rurl string) (string, int64, error)
- func FindInList(a string, arr []string) bool
- func GetBytes(data interface{}) ([]byte, error)
- func GetEnv(key string) string
- func GetFuncName(i interface{}) string
- func GetHostUrl(s string) string
- func GoDeferFunc(api string, f func())
- func HttpClient() *http.Client
- func InList(a string, list []string) bool
- func Init()
- func InitFunctionProfiler(fname string)
- func IsInt(val string) bool
- func List2Set(arr []string) []string
- func LoadExamples(ename, home string) string
- func MapKeys(rec map[string]interface{}) []string
- func Max(data []interface{}) float64
- func Mean(data []interface{}) float64
- func MeasureTime(funcName string) func()
- func Median(data []interface{}) float64
- func Min(data []interface{}) float64
- func Response(rurl string, data []byte) []byte
- func RunRegistryTime(ts string) string
- func SizeFormat(val interface{}) string
- func Stack() string
- func Sum(data []interface{}) float64
- func TimeFormat(ts interface{}) string
- func URLFetchWorker(in <-chan UrlRequest)
- func Unix2DASTime(ts int64) string
- func UnixTime(ts string) int64
- type Int64List
- type IntList
- type ResponseType
- type RucioAuthModule
- type StringList
- type TLSCertsManager
- type UrlFetchQueue
- type UrlRequest
Constants ¶
const ( DASServerError DBSError PhedexError RucioError DynamoError ReqMgrError RunRegistryError McMError DashboardError SiteDBError CRICError CondDBError CombinedError MongoDBError DASProxyError DASQueryError DASParserError DASValidationError )
DASServerError and others are represent different types of errors in DAS
const ( DASServerErrorName = "DAS error" DBSErrorName = "DBS upstream error" PhedexErrorName = "PhEDEx upstream error" RucioErrorName = "Rucio upstream error" DynamoErrorName = "Dynamo upstream error" ReqMgrErrorName = "ReqMgr upstream error" RunRegistryErrorName = "RunRegistry upstream error" McMErrorName = "McM upstream error" DashboardErrorName = "Dashboard upstream error" SiteDBErrorName = "SiteDB upstream error" CRICErrorName = "CRIC upstream error" CondDBErrorName = "CondDB upstream error" CombinedErrorName = "Combined error" MongoDBErrorName = "MongoDB error" DASProxyErrorName = "DAS proxy error" DASQueryErrorName = "DAS query error" DASParserErrorName = "DAS parser error" DASValidationErrorName = "DAS validation error" )
DASServerErrorName and others provides human based definition of the DAS error
const BLACK = "0;30m"
BLACK color
const BLUE = "0;34m"
BLUE color
const BOLD = "\x1b[1m"
BOLD type
const BROWN = "0;33m"
BROWN color
const CYAN = "0;36m"
CYAN color
const GREEN = "0;32m"
GREEN color
const LIGHT_CYAN = "1;36m"
LIGHT_CYAN color
const LIGHT_PURPLE = "1;35m"
LIGHT_PURPLE color
const PLAIN = "\x1b[0m"
PLAIN type
const PURPLE = "0;35m"
PURPLE color
const RED = "0;31m"
RED color
Variables ¶
var ( // UrlQueueSize keeps track of running URL requests UrlQueueSize int32 // UrlQueueLimit knows how many URL requests we can handle at a time, 0 means no limit UrlQueueLimit int32 // UrlRetry knows how many times we'll retry given url call UrlRetry int // UrlRequestChannel is a UrlRequest channel UrlRequestChannel = make(chan UrlRequest) )
var CLIENT_VERSION string
CLIENT_VERSION represents client version
var DASMAPS string
DASMAPS specifies location of dasmaps
var DNSCacheMgr *dcr.DNSManager
DNSCacheMgr manager
var KEEP_ALIVE bool
KEEP_ALIVE defines to use Keep-Alive HTTP header in HTTP requests https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive
var PatternBlock = regexp.MustCompile("/[-a-zA-Z_0-9*]+/[-a-zA-Z_0-9*]+/[-a-zA-Z_0-9*]+#.*")
PatternBlock represents CMS block
var PatternDataset = regexp.MustCompile("/[-a-zA-Z_0-9*]+/[-a-zA-Z_0-9*]+/[-a-zA-Z_0-9*]+")
PatternDataset represents CMS dataset
var PatternFile = regexp.MustCompile("/[a-zA-Z_0-9].*\\.root$")
PatternFile represents CMS file
var PatternInt = regexp.MustCompile("(^[0-9-]$|^[0-9-][0-9]*$)")
PatternInt represents an integer pattern
var PatternRun = regexp.MustCompile("[0-9]+")
PatternRun represents CMS run
var PatternSE = regexp.MustCompile("^[a-z]+(\\.)[a-z]+(\\.)")
PatternSE represents StorageElement pattern
var PatternSite = regexp.MustCompile("^T[0-9]_[A-Z]+(_)[A-Z]+")
PatternSite represents a site name pattern
var PatternUrl = regexp.MustCompile("(https|http)://[-A-Za-z0-9_+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]")
PatternUrl represents URL pattern
var Profiler *bufio.Writer
global variable
var RucioTokenCurl bool
RucioTokenCurl
var RucioValidity int64
RucioValidity
var TIMEOUT int
TIMEOUT defines timeout for net/url request
var TLSCertsRenewInterval time.Duration
TLSCertsRenewInterval controls interval to re-read TLS certs (in seconds)
var Token string
Token defines access token location
var TotalGetCalls uint64
TotalGetCalls counts total number of GET requests made by the server
var TotalPostCalls uint64
TotalPostCalls counts total number of POST requests made by the server
var UseDNSCache bool
UseDNSCache defines if we use DNS Cache resolver
var VERBOSE int
VERBOSE holds level of verbosity, it is set in main
var VERSION string
VERSION provides information about das2go build
var WEBSERVER int
WEBSERVER declares that web server will run, it is set in main
Functions ¶
func Avg ¶
func Avg(data []interface{}) float64
Avg helper function to perform Avg operation over provided array of values
func CertExpire ¶
func CertExpire(certs []tls.Certificate) time.Time
CertExpire gets minimum certificate expire from list of certificates
func CheckEntries ¶
CheckEntries helper function to check that entries from list1 are all appear in list2
func Color ¶
Color prints given string in color based on ANSI escape codes, see http://www.wikiwand.com/en/ANSI_escape_code#/Colors
func ConddbTime ¶
ConddbTime helper function to convert given time into Conddb timestamp
func DASError ¶
func DASError(args ...interface{})
DASError prints DAS error message with given arguments
func DASWarning ¶
func DASWarning(args ...interface{})
DASWarning prints DAS error message with given arguments
func DashboardTime ¶
DashboardTime helper function to convert given time into Dashboard timestamp
func EqualLists ¶
EqualLists helper function to compare list of strings
func ErrPropagate ¶
func ErrPropagate(api string)
ErrPropagate error helper function which can be used in defer ErrPropagate()
func ErrPropagate2Channel ¶
func ErrPropagate2Channel(api string, ch chan interface{})
ErrPropagate2Channel error helper function which can be used in goroutines as ch := make(chan interface{})
go func() { defer ErrPropagate2Channel(api, ch) someFunction() }()
func Fetch ¶
func Fetch(httpClient *http.Client, rurl string, args string, out chan<- ResponseType)
Fetch data for provided URL and redirect results to given channel This wrapper function look-up UrlQueueLimit and either redirect to URULFetchWorker go-routine or pass the call to local fetch function
func FetchRucioToken ¶
run go-routine to periodically obtain rucio token FetchRucioToken request new Rucio token
func FetchRucioTokenViaCurl ¶
FetchRucioTokenViaCurl is a helper function to get Rucio token by using curl command
func FindInList ¶
FindInList helper function to find item in a list
func GoDeferFunc ¶
func GoDeferFunc(api string, f func())
GoDeferFunc helper function to run any given function in defered go routine
func InitFunctionProfiler ¶
func InitFunctionProfiler(fname string)
func LoadExamples ¶
LoadExamples loads DAS examples from github or local file
func Max ¶
func Max(data []interface{}) float64
Max helper function to perform Max operation over provided array of values
func Mean ¶
func Mean(data []interface{}) float64
Mean helper function to perform Mean operation over provided array of values
func MeasureTime ¶
func MeasureTime(funcName string) func()
Latency Measurement of individual component of the codebase https://medium.com/swlh/easy-guide-to-latency-measurement-in-golang-38c3297ebbd2 Usage, put the following statement in any function we need to measure: defer measureTime("funcName")
func Median ¶
func Median(data []interface{}) float64
Median helper function to perform Median operation over provided array of values
func Min ¶
func Min(data []interface{}) float64
Min helper function to perform Min operation over provided array of values
func Response ¶
Response represents final response in a form of JSON structure we use custorm representation
func RunRegistryTime ¶
RunRegistryTime helper function to convert given time into RunRegistry timestamp
func SizeFormat ¶
func SizeFormat(val interface{}) string
SizeFormat helper function to convert size into human readable form
func Sum ¶
func Sum(data []interface{}) float64
Sum helper function to perform sum operation over provided array of values
func TimeFormat ¶
func TimeFormat(ts interface{}) string
TimeFormat helper function to convert Unix time into human readable form
func URLFetchWorker ¶
func URLFetchWorker(in <-chan UrlRequest)
URLFetchWorker has three channels: in channel for incoming requests (in a form of URL strings), out channel for outgoing responses in a form of ResponseType structure and quit channel
func Unix2DASTime ¶
Unix2DASTime helper function to convert given time into Unix timestamp
Types ¶
type Int64List ¶
type Int64List []int64
Int64List implement sort for []int type
type IntList ¶
type IntList []int
IntList implement sort for []int type
type ResponseType ¶
type ResponseType struct { Url string Data []byte Error error Time time.Duration Params string Method string SendBytes int RecvBytes int }
ResponseType structure is what we expect to get for our URL call. It contains a request URL, the data chunk and possible error from remote
func FetchResponse ¶
func FetchResponse(httpClient *http.Client, rurl, args string) ResponseType
FetchResponse fetches data for provided URL, args is a json dump of arguments
func (*ResponseType) Details ¶
func (r *ResponseType) Details() string
Details returns ResponseType details
func (*ResponseType) String ¶
func (r *ResponseType) String() string
String returns ResponseType representation
type RucioAuthModule ¶
type RucioAuthModule struct {
// contains filtered or unexported fields
}
RucioAuthModule structure holds all information about Rucio authentication
var RucioAuth RucioAuthModule
RucioAuth represents instance of rucio authentication module
func (*RucioAuthModule) Account ¶
func (r *RucioAuthModule) Account() string
Account returns Rucio authentication account
func (*RucioAuthModule) Agent ¶
func (r *RucioAuthModule) Agent() string
Agent returns Rucio authentication agent
func (*RucioAuthModule) String ¶
func (r *RucioAuthModule) String() string
String provides string representation of RucioAuthModule
func (*RucioAuthModule) Token ¶
func (r *RucioAuthModule) Token() (string, error)
Token returns Rucio authentication token
func (*RucioAuthModule) Url ¶
func (r *RucioAuthModule) Url() string
Url returns Rucio authentication url
type StringList ¶
type StringList []string
StringList implement sort for []string type
func (StringList) Less ¶
func (s StringList) Less(i, j int) bool
Less implements less function for []int type
func (StringList) Swap ¶
func (s StringList) Swap(i, j int)
Swap implements swap function for []int type
type TLSCertsManager ¶
type TLSCertsManager struct { Certs []tls.Certificate Expire time.Time }
TLSCerts holds TLS certificates for the server
func (*TLSCertsManager) GetCerts ¶
func (t *TLSCertsManager) GetCerts() ([]tls.Certificate, error)
GetCerts return fresh copy of certificates
type UrlFetchQueue ¶
type UrlFetchQueue []*UrlRequest
A UrlFetchQueue implements heap.Interface and holds UrlRequests
func (UrlFetchQueue) Len ¶
func (q UrlFetchQueue) Len() int
Len provides len implemenation for UrlFetchQueue
func (UrlFetchQueue) Less ¶
func (q UrlFetchQueue) Less(i, j int) bool
Less provides Less implemenation for UrlFetchQueue
func (*UrlFetchQueue) Pop ¶
func (q *UrlFetchQueue) Pop() interface{}
Pop provides Pop implemenation for UrlFetchQueue
func (*UrlFetchQueue) Push ¶
func (q *UrlFetchQueue) Push(x interface{})
Push provides push implemenation for UrlFetchQueue
func (UrlFetchQueue) Swap ¶
func (q UrlFetchQueue) Swap(i, j int)
Swap provides swap implemenation for UrlFetchQueue
type UrlRequest ¶
type UrlRequest struct {
// contains filtered or unexported fields
}
UrlRequest structure holds details about url request's attributes