_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15300 | Spin | train | func (t *task) Spin() {
// We need to lock long enough to change state
t.Lock()
defer t.Unlock()
// if this task is a streaming task
if t.isStream {
t.state = core.TaskSpinning
t.killChan = make(chan struct{})
go t.stream()
return
}
// Reset the lastFireTime at each Spin.
// This ensures misses are tra... | go | {
"resource": ""
} |
q15301 | stream | train | func (t *task) stream() {
var consecutiveFailures int
resetTime := time.Second * 3
for {
metricsChan, errChan, err := t.metricsManager.StreamMetrics(
t.id,
t.workflow.tags,
t.maxCollectDuration,
t.maxMetricsBuffer)
if err != nil {
consecutiveFailures++
// check task failures
if t.stopOnFailu... | go | {
"resource": ""
} |
q15302 | UnsubscribePlugins | train | func (t *task) UnsubscribePlugins() []serror.SnapError {
depGroups := getWorkflowPlugins(t.workflow.processNodes, t.workflow.publishNodes, t.workflow.metrics)
var errs []serror.SnapError
for k := range depGroups {
event := &scheduler_event.PluginsUnsubscribedEvent{
TaskID: t.ID(),
Plugins: depGroups[k].subs... | go | {
"resource": ""
} |
q15303 | SubscribePlugins | train | func (t *task) SubscribePlugins() ([]string, []serror.SnapError) {
depGroups := getWorkflowPlugins(t.workflow.processNodes, t.workflow.publishNodes, t.workflow.metrics)
var subbedDeps []string
for k := range depGroups {
var errs []serror.SnapError
mgr, err := t.RemoteManagers.Get(k)
if err != nil {
errs = a... | go | {
"resource": ""
} |
q15304 | Enable | train | func (t *task) Enable() error {
t.Lock()
defer t.Unlock()
if t.state != core.TaskDisabled {
return ErrTaskNotDisabled
}
t.state = core.TaskStopped
return nil
} | go | {
"resource": ""
} |
q15305 | disable | train | func (t *task) disable(failureMsg string) {
t.Lock()
t.state = core.TaskDisabled
t.Unlock()
// Send task disabled event
event := new(scheduler_event.TaskDisabledEvent)
event.TaskID = t.id
event.Why = fmt.Sprintf("Task disabled with error: %s", failureMsg)
defer t.eventEmitter.Emit(event)
} | go | {
"resource": ""
} |
q15306 | RecordFailure | train | func (t *task) RecordFailure(e []error) {
// We synchronize this update to ensure it is atomic
t.failureMutex.Lock()
defer t.failureMutex.Unlock()
t.failedRuns++
t.lastFailureTime = t.lastFireTime
t.lastFailureMessage = e[len(e)-1].Error()
} | go | {
"resource": ""
} |
q15307 | Get | train | func (t *taskCollection) Get(id string) *task {
t.Lock()
defer t.Unlock()
if t, ok := t.table[id]; ok {
return t
}
return nil
} | go | {
"resource": ""
} |
q15308 | add | train | func (t *taskCollection) add(task *task) error {
t.Lock()
defer t.Unlock()
if _, ok := t.table[task.id]; !ok {
//If we don't already have this task in the collection save it
t.table[task.id] = task
} else {
taskLogger.WithFields(log.Fields{
"_module": "scheduler-taskCollection",
"_block": "add",
"t... | go | {
"resource": ""
} |
q15309 | remove | train | func (t *taskCollection) remove(task *task) error {
t.Lock()
defer t.Unlock()
if _, ok := t.table[task.id]; ok {
if task.state != core.TaskStopped && task.state != core.TaskDisabled && task.state != core.TaskEnded {
taskLogger.WithFields(log.Fields{
"_block": "remove",
"task id": task.id,
}).Error(E... | go | {
"resource": ""
} |
q15310 | Table | train | func (t *taskCollection) Table() map[string]*task {
t.Lock()
defer t.Unlock()
tasks := make(map[string]*task)
for id, t := range t.table {
tasks[id] = t
}
return tasks
} | go | {
"resource": ""
} |
q15311 | createTaskClients | train | func createTaskClients(mgrs *managers, wf *schedulerWorkflow) error {
return walkWorkflow(wf.processNodes, wf.publishNodes, mgrs)
} | go | {
"resource": ""
} |
q15312 | Select | train | func (s *sticky) Select(aps []AvailablePlugin, taskID string) (AvailablePlugin, error) {
if ap, ok := s.plugins[taskID]; ok && ap != nil {
return ap, nil
}
return s.selectPlugin(aps, taskID)
} | go | {
"resource": ""
} |
q15313 | OptEnableRunnerTLS | train | func OptEnableRunnerTLS(grpcSecurity client.GRPCSecurity) pluginRunnerOpt {
return func(r *runner) {
r.grpcSecurity = grpcSecurity
}
} | go | {
"resource": ""
} |
q15314 | Start | train | func (r *runner) Start() error {
// Delegates must be added before starting if none exist
// then this Runner can do nothing and should not start.
if len(r.delegates) == 0 {
return errors.New("No delegates added before called Start()")
}
// For each delegate register needed handlers
for _, del := range r.deleg... | go | {
"resource": ""
} |
q15315 | Stop | train | func (r *runner) Stop() []error {
var errs []error
// Stop the monitor
r.monitor.Stop()
// TODO: Actually stop the plugins
// For each delegate unregister needed handlers
for _, del := range r.delegates {
e := del.UnregisterHandler(HandlerRegistrationName)
if e != nil {
errs = append(errs, e)
}
}
de... | go | {
"resource": ""
} |
q15316 | HandleGomitEvent | train | func (r *runner) HandleGomitEvent(e gomit.Event) {
switch v := e.Body.(type) {
case *control_event.DeadAvailablePluginEvent:
runnerLog.WithFields(log.Fields{
"_block": "handle-events",
"event": v.Namespace(),
"aplugin": v.String,
}).Warning("handling dead available plugin event")
pool, err := r.ava... | go | {
"resource": ""
} |
q15317 | Start | train | func (q *queue) Start() {
q.mutex.Lock()
defer q.mutex.Unlock()
if q.status == queueStopped {
q.status = queueRunning
go q.start()
}
} | go | {
"resource": ""
} |
q15318 | Stop | train | func (q *queue) Stop() {
q.mutex.Lock()
defer q.mutex.Unlock()
if q.status != queueStopped {
close(q.kill)
q.status = queueStopped
}
} | go | {
"resource": ""
} |
q15319 | IsUri | train | func IsUri(url string) bool {
if !govalidator.IsURL(url) || !strings.HasPrefix(url, "http") {
return false
}
return true
} | go | {
"resource": ""
} |
q15320 | MarshalJSON | train | func (i *IntRule) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Key string `json:"key"`
Required bool `json:"required"`
Default ctypes.ConfigValue `json:"default,omitempty"`
Minimum ctypes.ConfigValue `json:"minimum,omitempty"`
Maximum ctypes.ConfigValue `jso... | go | {
"resource": ""
} |
q15321 | GobDecode | train | func (i *IntRule) GobDecode(buf []byte) error {
r := bytes.NewBuffer(buf)
decoder := gob.NewDecoder(r)
if err := decoder.Decode(&i.key); err != nil {
return err
}
if err := decoder.Decode(&i.required); err != nil {
return err
}
var is_default_set bool
decoder.Decode(&is_default_set)
if is_default_set {
r... | go | {
"resource": ""
} |
q15322 | Default | train | func (i *IntRule) Default() ctypes.ConfigValue {
if i.default_ != nil {
return ctypes.ConfigValueInt{Value: *i.default_}
}
return nil
} | go | {
"resource": ""
} |
q15323 | readConfig | train | func readConfig(cfg *Config, fpath string) {
var path string
if !defaultConfigFile() && fpath == "" {
return
}
if defaultConfigFile() && fpath == "" {
path = defaultConfigPath
}
if fpath != "" {
f, err := os.Stat(fpath)
if err != nil {
log.Fatal(err)
}
if f.IsDir() {
log.Fatal("configuration pat... | go | {
"resource": ""
} |
q15324 | setBoolVal | train | func setBoolVal(field bool, ctx runtimeFlagsContext, flagName string, inverse ...bool) bool {
// check to see if a value was set (either on the command-line or via the associated
// environment variable, if any); if so, use that as value for the input field
val := ctx.Bool(flagName)
if ctx.IsSet(flagName) || val {
... | go | {
"resource": ""
} |
q15325 | checkCmdLineFlags | train | func checkCmdLineFlags(ctx runtimeFlagsContext) (int, bool, error) {
tlsCert := ctx.String("tls-cert")
tlsKey := ctx.String("tls-key")
if _, err := checkTLSEnabled(tlsCert, tlsKey, commandLineErrorPrefix); err != nil {
return -1, false, err
}
// Check to see if the API address is specified (either via the CLI or... | go | {
"resource": ""
} |
q15326 | checkCfgSettings | train | func checkCfgSettings(cfg *Config) (int, bool, error) {
tlsCert := cfg.Control.TLSCertPath
tlsKey := cfg.Control.TLSKeyPath
if _, err := checkTLSEnabled(tlsCert, tlsKey, configFileErrorPrefix); err != nil {
return -1, false, err
}
addr := cfg.RestAPI.Address
var port int
if cfg.RestAPI.PortSetByConfigFile() {
... | go | {
"resource": ""
} |
q15327 | setMaxProcs | train | func setMaxProcs(maxProcs int) {
var _maxProcs int
numProcs := runtime.NumCPU()
if maxProcs <= 0 {
// We prefer sane values for GOMAXPROCS
log.WithFields(
log.Fields{
"_block": "main",
"_module": logModule,
"maxprocs": maxProcs,
}).Error("Trying to set GOMAXPROCS to an invalid value")
_max... | go | {
"resource": ""
} |
q15328 | New | train | func New(e error, fields ...map[string]interface{}) *snapError {
// Catch someone trying to wrap a serror around a serror.
// We throw a panic to make them fix this.
if _, ok := e.(SnapError); ok {
panic("You are trying to wrap a snapError around a snapError. Don't do this.")
}
p := &snapError{
err: e,
f... | go | {
"resource": ""
} |
q15329 | MonitorDurationOption | train | func MonitorDurationOption(v time.Duration) monitorOption {
return func(m *monitor) monitorOption {
previous := m.duration
m.duration = v
return MonitorDurationOption(previous)
}
} | go | {
"resource": ""
} |
q15330 | Start | train | func (m *monitor) Start(availablePlugins *availablePlugins) {
//start a routine that will be fired every X duration looping
//over available plugins and firing a health check routine
ticker := time.NewTicker(m.duration)
m.quit = make(chan struct{})
go func() {
for {
select {
case <-ticker.C:
go func() ... | go | {
"resource": ""
} |
q15331 | GetConfigPolicy | train | func (f *Mock) GetConfigPolicy() (plugin.ConfigPolicy, error) {
p := plugin.NewConfigPolicy()
err := p.AddNewStringRule([]string{"intel", "mock", "test%>"}, "name", false, plugin.SetDefaultString("bob"))
if err != nil {
return *p, err
}
err = p.AddNewStringRule([]string{"intel", "mock", "/foo=㊽"}, "password", ... | go | {
"resource": ""
} |
q15332 | GetPluginConfig | train | func (c *Client) GetPluginConfig(pluginType, name, version string) *GetPluginConfigResult {
r := &GetPluginConfigResult{}
resp, err := c.do("GET", fmt.Sprintf("/plugins/%s/%s/%s/config", pluginType, url.QueryEscape(name), version), ContentTypeJSON)
if err != nil {
r.Err = err
return r
}
switch resp.Meta.Type ... | go | {
"resource": ""
} |
q15333 | SetPluginConfig | train | func (c *Client) SetPluginConfig(pluginType, name, version string, key string, value ctypes.ConfigValue) *SetPluginConfigResult {
r := &SetPluginConfigResult{}
b, err := json.Marshal(map[string]ctypes.ConfigValue{key: value})
if err != nil {
r.Err = err
return r
}
resp, err := c.do("PUT", fmt.Sprintf("/plugins... | go | {
"resource": ""
} |
q15334 | DeletePluginConfig | train | func (c *Client) DeletePluginConfig(pluginType, name, version string, key string) *DeletePluginConfigResult {
r := &DeletePluginConfigResult{}
b, err := json.Marshal([]string{key})
if err != nil {
r.Err = err
return r
}
resp, err := c.do("DELETE", fmt.Sprintf("/plugins/%s/%s/%s/config", pluginType, url.QueryEs... | go | {
"resource": ""
} |
q15335 | init | train | func init() {
host, err := os.Hostname()
if err != nil {
log.WithFields(log.Fields{
"_module": "control",
"_file": "metrics.go,",
"_block": "addStandardAndWorkflowTags",
"error": err.Error(),
}).Error("Unable to determine hostname")
host = "not_found"
}
hostnameReader = &hostnameReaderType{ho... | go | {
"resource": ""
} |
q15336 | RmUnloadedPluginMetrics | train | func (mc *metricCatalog) RmUnloadedPluginMetrics(lp *loadedPlugin) {
mc.mutex.Lock()
defer mc.mutex.Unlock()
mc.tree.DeleteByPlugin(lp)
// Update metric catalog keys
mc.keys = []string{}
mts := mc.tree.gatherMetricTypes()
for _, m := range mts {
mc.keys = append(mc.keys, m.Namespace().String())
}
} | go | {
"resource": ""
} |
q15337 | Add | train | func (mc *metricCatalog) Add(m *metricType) {
mc.mutex.Lock()
defer mc.mutex.Unlock()
key := m.Namespace().String()
// adding key as a cataloged keys (mc.keys)
mc.keys = appendIfMissing(mc.keys, key)
mc.tree.Add(m)
} | go | {
"resource": ""
} |
q15338 | GetMetric | train | func (mc *metricCatalog) GetMetric(requested core.Namespace, version int) (*metricType, error) {
mc.mutex.Lock()
defer mc.mutex.Unlock()
var ns core.Namespace
catalogedmt, err := mc.tree.GetMetric(requested.Strings(), version)
if err != nil {
log.WithFields(log.Fields{
"_module": "control",
"_file": "m... | go | {
"resource": ""
} |
q15339 | GetVersions | train | func (mc *metricCatalog) GetVersions(ns core.Namespace) ([]*metricType, error) {
mc.mutex.Lock()
defer mc.mutex.Unlock()
mts, err := mc.tree.GetVersions(ns.Strings())
if err != nil {
log.WithFields(log.Fields{
"_module": "control",
"_file": "metrics.go,",
"_block": "get-versions",
"error": err,
... | go | {
"resource": ""
} |
q15340 | Remove | train | func (mc *metricCatalog) Remove(ns core.Namespace) {
mc.mutex.Lock()
defer mc.mutex.Unlock()
mc.tree.Remove(ns.Strings())
} | go | {
"resource": ""
} |
q15341 | Subscribe | train | func (mc *metricCatalog) Subscribe(ns []string, version int) error {
mc.mutex.Lock()
defer mc.mutex.Unlock()
m, err := mc.tree.GetMetric(ns, version)
if err != nil {
log.WithFields(log.Fields{
"_module": "control",
"_file": "metrics.go,",
"_block": "subscribe",
"error": err,
}).Error("error ge... | go | {
"resource": ""
} |
q15342 | containsTuple | train | func containsTuple(nsElement string) (bool, []string) {
tupleItems := []string{}
if isTuple(nsElement) {
if strings.ContainsAny(nsElement, "*") {
// an asterisk covers all tuples cases (eg. /intel/mock/(host0;host1;*)/baz)
// so to avoid retrieving the same metric more than once, return only '*' as a tuple's ... | go | {
"resource": ""
} |
q15343 | specifyInstanceOfDynamicMetric | train | func specifyInstanceOfDynamicMetric(catalogedNamespace core.Namespace, requestedNamespace core.Namespace) core.Namespace {
specifiedNamespace := make(core.Namespace, len(catalogedNamespace))
copy(specifiedNamespace, catalogedNamespace)
_, indexes := catalogedNamespace.IsDynamic()
for _, index := range indexes {
... | go | {
"resource": ""
} |
q15344 | validateMetricNamespace | train | func validateMetricNamespace(ns core.Namespace) error {
value := ""
for _, i := range ns {
// A dynamic element requires the name while a static element does not.
if i.Name != "" && i.Value != "*" {
return errorMetricStaticElementHasName(i.Value, i.Name, ns.String())
}
if i.Name == "" && i.Value == "*" {
... | go | {
"resource": ""
} |
q15345 | MarshalJSON | train | func (b *BoolRule) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Key string `json:"key"`
Required bool `json:"required"`
Default ctypes.ConfigValue `json:"default,omitempty"`
Type string `json:"type"`
}{
Key: b.key,
Required: b.required,... | go | {
"resource": ""
} |
q15346 | GobEncode | train | func (b *BoolRule) GobEncode() ([]byte, error) {
w := new(bytes.Buffer)
encoder := gob.NewEncoder(w)
if err := encoder.Encode(b.key); err != nil {
return nil, err
}
if err := encoder.Encode(b.required); err != nil {
return nil, err
}
if b.default_ == nil {
encoder.Encode(false)
} else {
encoder.Encode(t... | go | {
"resource": ""
} |
q15347 | GobDecode | train | func (b *BoolRule) GobDecode(buf []byte) error {
r := bytes.NewBuffer(buf)
decoder := gob.NewDecoder(r)
if err := decoder.Decode(&b.key); err != nil {
return err
}
if err := decoder.Decode(&b.required); err != nil {
return err
}
var isDefaultSet bool
decoder.Decode(&isDefaultSet)
if isDefaultSet {
return... | go | {
"resource": ""
} |
q15348 | Validate | train | func (b *BoolRule) Validate(cv ctypes.ConfigValue) error {
// Check that type is correct
if cv.Type() != BoolType {
return wrongType(b.key, cv.Type(), BoolType)
}
return nil
} | go | {
"resource": ""
} |
q15349 | Default | train | func (b *BoolRule) Default() ctypes.ConfigValue {
if b.default_ != nil {
return ctypes.ConfigValueBool{Value: *b.default_}
}
return nil
} | go | {
"resource": ""
} |
q15350 | GetConfigPolicy | train | func (s *SessionState) GetConfigPolicy(args []byte, reply *[]byte) error {
defer catchPluginPanic(s.Logger())
s.logger.Debug("GetConfigPolicy called")
policy, err := s.plugin.GetConfigPolicy()
if err != nil {
return errors.New(fmt.Sprintf("GetConfigPolicy call error : %s", err.Error()))
}
r := GetConfigPolic... | go | {
"resource": ""
} |
q15351 | Ping | train | func (s *SessionState) Ping(arg []byte, reply *[]byte) error {
// For now we return nil. We can return an error if we are shutting
// down or otherwise in a state we should signal poor health.
// Reply should contain any context.
s.ResetHeartbeat()
s.logger.Debug("Ping received")
*reply = []byte{}
return nil
} | go | {
"resource": ""
} |
q15352 | Kill | train | func (s *SessionState) Kill(args []byte, reply *[]byte) error {
a := &KillArgs{}
err := s.Decode(args, a)
if err != nil {
return err
}
s.logger.Debugf("Kill called by agent, reason: %s\n", a.Reason)
go func() {
time.Sleep(time.Second * 2)
s.killChan <- 0
}()
*reply = []byte{}
return nil
} | go | {
"resource": ""
} |
q15353 | DeleteByPlugin | train | func (m *MTTrie) DeleteByPlugin(cp core.CatalogedPlugin) {
for _, mt := range m.gatherMetricTypes() {
mtPluginKey := fmt.Sprintf("%s"+core.Separator+"%s"+core.Separator+"%d", mt.Plugin.TypeName(), mt.Plugin.Name(), mt.Plugin.Version())
cpKey := fmt.Sprintf("%s"+core.Separator+"%s"+core.Separator+"%d", cp.TypeName(... | go | {
"resource": ""
} |
q15354 | RemoveMetric | train | func (m *MTTrie) RemoveMetric(mt metricType) {
a, _ := m.find(mt.Namespace().Strings())
if a != nil {
for v, x := range a.mts {
if mt.Version() == x.Version() {
// delete this metric from the node
delete(a.mts, v)
}
}
}
} | go | {
"resource": ""
} |
q15355 | Add | train | func (mtt *mttNode) Add(mt *metricType) {
ns := mt.Namespace()
node, index := mtt.walk(ns.Strings())
if index == len(ns) {
if node.mts == nil {
node.mts = make(map[int]*metricType)
}
node.mts[mt.Version()] = mt
return
}
// walk through the remaining namespace and build out the
// new branch in the trie... | go | {
"resource": ""
} |
q15356 | Fetch | train | func (mtt *mttNode) Fetch(ns []string) ([]*metricType, error) {
children := mtt.fetch(ns)
var mts []*metricType
for _, child := range children {
for _, mt := range child.mts {
mts = append(mts, mt)
}
}
if len(mts) == 0 && len(ns) > 0 {
return nil, errorMetricsNotFound("/" + strings.Join(ns, "/"))
}
retu... | go | {
"resource": ""
} |
q15357 | Remove | train | func (mtt *mttNode) Remove(ns []string) error {
_, err := mtt.find(ns)
if err != nil {
return err
}
parent, err := mtt.find(ns[:len(ns)-1])
if err != nil {
return err
}
// remove node from parent
delete(parent.children, ns[len(ns)-1:][0])
return nil
} | go | {
"resource": ""
} |
q15358 | GetVersions | train | func (mtt *mttNode) GetVersions(ns []string) ([]*metricType, error) {
var nodes []*mttNode
var mts []*metricType
if len(ns) == 0 {
return nil, errorEmptyNamespace()
}
nodes = mtt.search(nodes, ns)
for _, node := range nodes {
// concatenates metric types in ALL versions into a single slice
for _, mt := r... | go | {
"resource": ""
} |
q15359 | fetch | train | func (mtt *mttNode) fetch(ns []string) []*mttNode {
node, err := mtt.find(ns)
if err != nil {
return nil
}
var children []*mttNode
if node.mts != nil {
children = append(children, node)
}
if node.children != nil {
children = gatherDescendants(children, node)
}
return children
} | go | {
"resource": ""
} |
q15360 | search | train | func (mtt *mttNode) search(nodes []*mttNode, ns []string) []*mttNode {
parent := mtt
var children []*mttNode
if parent.children == nil {
return nodes
}
if len(ns) == 1 {
// the last element of ns is under searching process
switch ns[0] {
case "*":
// fetch all descendants when wildcard ends namespace
... | go | {
"resource": ""
} |
q15361 | gatherDescendants | train | func gatherDescendants(descendants []*mttNode, node *mttNode) []*mttNode {
for _, child := range node.children {
if child.mts != nil {
descendants = append(descendants, child)
}
if child.children != nil {
descendants = gatherDescendants(descendants, child)
}
}
return descendants
} | go | {
"resource": ""
} |
q15362 | MarshalJSON | train | func (s *StringRule) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Key string `json:"key"`
Required bool `json:"required"`
Default ctypes.ConfigValue `json:"default"`
Type string `json:"type"`
}{
Key: s.key,
Required: s.required,
Defau... | go | {
"resource": ""
} |
q15363 | GobDecode | train | func (s *StringRule) GobDecode(buf []byte) error {
r := bytes.NewBuffer(buf)
decoder := gob.NewDecoder(r)
if err := decoder.Decode(&s.key); err != nil {
return err
}
if err := decoder.Decode(&s.required); err != nil {
return err
}
var is_default_set bool
decoder.Decode(&is_default_set)
if is_default_set {
... | go | {
"resource": ""
} |
q15364 | Validate | train | func (s *StringRule) Validate(cv ctypes.ConfigValue) error {
// Check that type is correct
if cv.Type() != StringType {
return wrongType(s.key, cv.Type(), StringType)
}
return nil
} | go | {
"resource": ""
} |
q15365 | Default | train | func (s *StringRule) Default() ctypes.ConfigValue {
if s.default_ != nil {
return ctypes.ConfigValueStr{Value: *s.default_}
}
return nil
} | go | {
"resource": ""
} |
q15366 | Stop | train | func (a *availablePlugin) Stop(r string) error {
log.WithFields(log.Fields{
"_module": "control-aplugin",
"block": "stop",
"plugin_name": a,
}).Info("stopping available plugin")
if a.IsRemote() {
return a.client.Close()
}
return a.client.Kill(r)
} | go | {
"resource": ""
} |
q15367 | Kill | train | func (a *availablePlugin) Kill(r string) error {
log.WithFields(log.Fields{
"_module": "control-aplugin",
"block": "kill",
"plugin_name": a,
}).Info("hard killing available plugin")
if a.fromPackage {
log.WithFields(log.Fields{
"_module": "control-aplugin",
"block": "kill",
"plug... | go | {
"resource": ""
} |
q15368 | CheckHealth | train | func (a *availablePlugin) CheckHealth() {
go func() {
a.healthChan <- a.client.Ping()
}()
select {
case err := <-a.healthChan:
if err == nil {
if a.failedHealthChecks > 0 {
// only log on first ok health check
log.WithFields(log.Fields{
"_module": "control-aplugin",
"block": "chec... | go | {
"resource": ""
} |
q15369 | healthCheckFailed | train | func (a *availablePlugin) healthCheckFailed() {
log.WithFields(log.Fields{
"_module": "control-aplugin",
"block": "check-health",
"plugin_name": a,
}).Warning("heartbeat missed")
a.failedHealthChecks++
if a.failedHealthChecks >= DefaultHealthCheckFailureLimit {
log.WithFields(log.Fields{
"_modu... | go | {
"resource": ""
} |
q15370 | CreateTask | train | func (c *Client) CreateTask(s *Schedule, wf *wmap.WorkflowMap, name string, deadline string, startTask bool, maxFailures int) *CreateTaskResult {
t := core.TaskCreationRequest{
Schedule: &core.Schedule{
Type: s.Type,
Interval: s.Interval,
StartTimestamp: s.StartTimestamp,
StopTimestamp: ... | go | {
"resource": ""
} |
q15371 | WatchTask | train | func (c *Client) WatchTask(id string) *WatchTasksResult {
// during watch we don't want to have a timeout
// Store the old timeout so we can restore when we are through
oldTimeout := c.http.Timeout
c.http.Timeout = time.Duration(0)
r := &WatchTasksResult{
EventChan: make(chan *rbody.StreamedTaskEvent),
DoneCh... | go | {
"resource": ""
} |
q15372 | GetTasks | train | func (c *Client) GetTasks() *GetTasksResult {
resp, err := c.do("GET", "/tasks", ContentTypeJSON, nil)
if err != nil {
return &GetTasksResult{Err: err}
}
switch resp.Meta.Type {
case rbody.ScheduledTaskListReturnedType:
// Success
return &GetTasksResult{resp.Body.(*rbody.ScheduledTaskListReturned), nil}
ca... | go | {
"resource": ""
} |
q15373 | GetTask | train | func (c *Client) GetTask(id string) *GetTaskResult {
resp, err := c.do("GET", fmt.Sprintf("/tasks/%v", id), ContentTypeJSON, nil)
if err != nil {
return &GetTaskResult{Err: err}
}
switch resp.Meta.Type {
case rbody.ScheduledTaskReturnedType:
// Success
return &GetTaskResult{resp.Body.(*rbody.ScheduledTaskRet... | go | {
"resource": ""
} |
q15374 | StartTask | train | func (c *Client) StartTask(id string) *StartTasksResult {
resp, err := c.do("PUT", fmt.Sprintf("/tasks/%v/start", id), ContentTypeJSON)
if err != nil {
return &StartTasksResult{Err: err}
}
switch resp.Meta.Type {
case rbody.ScheduledTaskStartedType:
// Success
return &StartTasksResult{resp.Body.(*rbody.Sch... | go | {
"resource": ""
} |
q15375 | StopTask | train | func (c *Client) StopTask(id string) *StopTasksResult {
resp, err := c.do("PUT", fmt.Sprintf("/tasks/%v/stop", id), ContentTypeJSON)
if err != nil {
return &StopTasksResult{Err: err}
}
if resp == nil {
return nil
}
switch resp.Meta.Type {
case rbody.ScheduledTaskStoppedType:
// Success
return &StopTasks... | go | {
"resource": ""
} |
q15376 | RemoveTask | train | func (c *Client) RemoveTask(id string) *RemoveTasksResult {
resp, err := c.do("DELETE", fmt.Sprintf("/tasks/%v", id), ContentTypeJSON)
if err != nil {
return &RemoveTasksResult{Err: err}
}
switch resp.Meta.Type {
case rbody.ScheduledTaskRemovedType:
// Success
return &RemoveTasksResult{resp.Body.(*rbody.Sch... | go | {
"resource": ""
} |
q15377 | EnableTask | train | func (c *Client) EnableTask(id string) *EnableTaskResult {
resp, err := c.do("PUT", fmt.Sprintf("/tasks/%v/enable", id), ContentTypeJSON)
if err != nil {
return &EnableTaskResult{Err: err}
}
switch resp.Meta.Type {
case rbody.ScheduledTaskEnabledType:
return &EnableTaskResult{resp.Body.(*rbody.ScheduledTaskEn... | go | {
"resource": ""
} |
q15378 | UnmarshalJSON | train | func (c *ConfigPolicyNode) UnmarshalJSON(data []byte) error {
m := map[string]interface{}{}
decoder := json.NewDecoder(bytes.NewReader(data))
if err := decoder.Decode(&m); err != nil {
return err
}
if rs, ok := m["rules"]; ok {
if rules, ok := rs.(map[string]interface{}); ok {
addRulesToConfigPolicyNode(rul... | go | {
"resource": ""
} |
q15379 | Add | train | func (p *ConfigPolicyNode) Add(rules ...Rule) {
p.mutex.Lock()
defer p.mutex.Unlock()
for _, r := range rules {
p.rules[r.Key()] = r
}
} | go | {
"resource": ""
} |
q15380 | Process | train | func (c *ConfigPolicyNode) Process(m map[string]ctypes.ConfigValue) (*map[string]ctypes.ConfigValue, *ProcessingErrors) {
c.mutex.Lock()
defer c.mutex.Unlock()
pErrors := NewProcessingErrors()
// Loop through each rule and process
for key, rule := range c.rules {
// items exists for rule
if cv, ok := m[key]; o... | go | {
"resource": ""
} |
q15381 | addRulesToConfigPolicyNode | train | func addRulesToConfigPolicyNode(rules map[string]interface{}, cpn *ConfigPolicyNode) error {
for k, rule := range rules {
if rule, ok := rule.(map[string]interface{}); ok {
req, _ := rule["required"].(bool)
switch rule["type"] {
case "integer":
r, _ := NewIntegerRule(k, req)
if d, ok := rule["defaul... | go | {
"resource": ""
} |
q15382 | SetCertPath | train | func (a Arg) SetCertPath(certPath string) Arg {
a.CertPath = certPath
return a
} | go | {
"resource": ""
} |
q15383 | SetKeyPath | train | func (a Arg) SetKeyPath(keyPath string) Arg {
a.KeyPath = keyPath
return a
} | go | {
"resource": ""
} |
q15384 | SetTLSEnabled | train | func (a Arg) SetTLSEnabled(tlsEnabled bool) Arg {
a.TLSEnabled = tlsEnabled
return a
} | go | {
"resource": ""
} |
q15385 | SetCACertPaths | train | func (a Arg) SetCACertPaths(caCertPaths string) Arg {
a.CACertPaths = caCertPaths
return a
} | go | {
"resource": ""
} |
q15386 | NewArg | train | func NewArg(logLevel int, pprof bool) Arg {
return Arg{
LogLevel: log.Level(logLevel),
PingTimeoutDuration: PingTimeoutDurationDefault,
Pprof: pprof,
}
} | go | {
"resource": ""
} |
q15387 | NewWindowedSchedule | train | func NewWindowedSchedule(i time.Duration, start *time.Time, stop *time.Time, count uint) *WindowedSchedule {
// if stop and count were both defined, ignore the `count`
if count != 0 && stop != nil {
count = 0
// log about ignoring the `count`
logger.WithFields(log.Fields{
"_block": "NewWindowedSchedule",
}... | go | {
"resource": ""
} |
q15388 | setStopOnTime | train | func (w *WindowedSchedule) setStopOnTime() {
if w.StopTime == nil && w.Count != 0 {
// determine the window stop based on the `count` and `interval`
var newStop time.Time
// if start is not set or points in the past,
// use the current time to calculate stopOnTime
if w.StartTime != nil && time.Now().Before(... | go | {
"resource": ""
} |
q15389 | Validate | train | func (w *WindowedSchedule) Validate() error {
// if the stop time was set but it is in the past, return an error
if w.StopTime != nil && time.Now().After(*w.StopTime) {
return ErrInvalidStopTime
}
// if the start and stop time were both set and the stop time is before
// the start time, return an error
if w.St... | go | {
"resource": ""
} |
q15390 | Wait | train | func (w *WindowedSchedule) Wait(last time.Time) Response {
// If within the window we wait our interval and return
// otherwise we exit with a completed state.
var m uint
if (last == time.Time{}) {
// the first waiting in cycles, so
// set the `stopOnTime` determining the right-window boundary
w.setStopOnTim... | go | {
"resource": ""
} |
q15391 | GetIP | train | func GetIP() string {
ifaces, err := net.Interfaces()
if err != nil {
return "127.0.0.1"
}
for _, i := range ifaces {
addrs, err := i.Addrs()
if err != nil {
return "127.0.0.1"
}
for _, addr := range addrs {
var ip net.IP
switch v := addr.(type) {
case *net.IPAddr:
ip = v.IP
case *net.I... | go | {
"resource": ""
} |
q15392 | add | train | func (l *loadedPlugins) add(lp *loadedPlugin) serror.SnapError {
l.Lock()
defer l.Unlock()
if _, exists := l.table[lp.Key()]; exists {
return serror.New(ErrPluginAlreadyLoaded, map[string]interface{}{
"plugin-name": lp.Meta.Name,
"plugin-version": lp.Meta.Version,
"plugin-type": lp.Type.String(),
... | go | {
"resource": ""
} |
q15393 | get | train | func (l *loadedPlugins) get(key string) (*loadedPlugin, error) {
l.RLock()
defer l.RUnlock()
lp, ok := l.table[key]
if !ok {
tnv := strings.Split(key, core.Separator)
if len(tnv) != 3 {
return nil, ErrBadKey
}
v, err := strconv.Atoi(tnv[2])
if err != nil {
return nil, ErrBadKey
}
if v < 1 {
... | go | {
"resource": ""
} |
q15394 | Key | train | func (lp *loadedPlugin) Key() string {
return fmt.Sprintf("%s"+core.Separator+"%s"+core.Separator+"%d", lp.TypeName(), lp.Name(), lp.Version())
} | go | {
"resource": ""
} |
q15395 | OptEnableManagerTLS | train | func OptEnableManagerTLS(grpcSecurity client.GRPCSecurity) pluginManagerOpt {
return func(p *pluginManager) {
p.grpcSecurity = grpcSecurity
}
} | go | {
"resource": ""
} |
q15396 | OptSetPluginTags | train | func OptSetPluginTags(tags map[string]map[string]string) pluginManagerOpt {
return func(p *pluginManager) {
p.pluginTags = tags
}
} | go | {
"resource": ""
} |
q15397 | SetPluginTags | train | func (p *pluginManager) SetPluginTags(tags map[string]map[string]string) {
p.pluginTags = tags
} | go | {
"resource": ""
} |
q15398 | GenerateArgs | train | func (p *pluginManager) GenerateArgs(logLevel int) plugin.Arg {
return plugin.NewArg(logLevel, p.pprof)
} | go | {
"resource": ""
} |
q15399 | New | train | func New(cfg *Config) (*Server, error) {
// pull a few parameters from the configuration passed in by snapteld
s := &Server{
err: make(chan error),
killChan: make(chan struct{}),
addrString: cfg.Address,
pprof: cfg.Pprof,
}
if cfg.HTTPS {
var err error
s.snapTLS, err = newtls(cfg.RestCerti... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.