本文整理汇总了Golang中github.com/outbrain/orchestrator/Godeps/_workspace/src/github.com/outbrain/golib/sqlutils.Args函数的典型用法代码示例。如果您正苦于以下问题:Golang Args函数的具体用法?Golang Args怎么用?Golang Args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Args函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ReadSeedStates
// SeedOperationState reads states for a given seed operation
func ReadSeedStates(seedId int64) ([]SeedOperationState, error) {
res := []SeedOperationState{}
query := `
select
agent_seed_state_id,
agent_seed_id,
state_timestamp,
state_action,
error_message
from
agent_seed_state
where
agent_seed_id = ?
order by
agent_seed_state_id desc
`
err := db.QueryOrchestrator(query, sqlutils.Args(seedId), func(m sqlutils.RowMap) error {
seedState := SeedOperationState{}
seedState.SeedStateId = m.GetInt64("agent_seed_state_id")
seedState.SeedId = m.GetInt64("agent_seed_id")
seedState.StateTimestamp = m.GetString("state_timestamp")
seedState.Action = m.GetString("state_action")
seedState.ErrorMessage = m.GetString("error_message")
res = append(res, seedState)
return nil
})
if err != nil {
log.Errore(err)
}
return res, err
}
示例2: readAgentBasicInfo
// readAgentBasicInfo returns the basic data for an agent directly from backend table (no agent access)
func readAgentBasicInfo(hostname string) (Agent, string, error) {
agent := Agent{}
token := ""
query := `
select
hostname,
port,
token,
last_submitted,
mysql_port
from
host_agent
where
hostname = ?
`
err := db.QueryOrchestrator(query, sqlutils.Args(hostname), func(m sqlutils.RowMap) error {
agent.Hostname = m.GetString("hostname")
agent.Port = m.GetInt("port")
agent.LastSubmitted = m.GetString("last_submitted")
agent.MySQLPort = m.GetInt64("mysql_port")
token = m.GetString("token")
return nil
})
if err != nil {
return agent, "", err
}
if token == "" {
return agent, "", log.Errorf("Cannot get agent/token: %s", hostname)
}
return agent, token, nil
}
示例3: ReadMaintenanceInstanceKey
// ReadMaintenanceInstanceKey will return the instanceKey for active maintenance by maintenanceToken
func ReadMaintenanceInstanceKey(maintenanceToken int64) (*InstanceKey, error) {
var res *InstanceKey
query := `
select
hostname, port
from
database_instance_maintenance
where
database_instance_maintenance_id = ?
`
err := db.QueryOrchestrator(query, sqlutils.Args(maintenanceToken), func(m sqlutils.RowMap) error {
instanceKey, merr := NewInstanceKeyFromStrings(m.GetString("hostname"), m.GetString("port"))
if merr != nil {
return merr
}
res = instanceKey
return nil
})
if err != nil {
log.Errore(err)
}
return res, err
}
示例4: AgentSeedDetails
// AgentSeedDetails reads details from backend table
func AgentSeedDetails(seedId int64) ([]SeedOperation, error) {
whereCondition := `
where
agent_seed_id = ?
`
return readSeeds(whereCondition, sqlutils.Args(seedId), "")
}
示例5: ReadClusterPoolInstances
func ReadClusterPoolInstances(clusterName string) (*PoolInstancesMap, error) {
var poolInstancesMap = make(PoolInstancesMap)
query := `
select
database_instance_pool.*
from
database_instance
join database_instance_pool using (hostname, port)
where
database_instance.cluster_name = ?
`
err := db.QueryOrchestrator(query, sqlutils.Args(clusterName), func(m sqlutils.RowMap) error {
pool := m.GetString("pool")
hostname := m.GetString("hostname")
port := m.GetInt("port")
if _, ok := poolInstancesMap[pool]; !ok {
poolInstancesMap[pool] = [](*InstanceKey){}
}
poolInstancesMap[pool] = append(poolInstancesMap[pool], &InstanceKey{Hostname: hostname, Port: port})
return nil
})
if err != nil {
return nil, err
}
return &poolInstancesMap, nil
}
示例6: readAvailableNodes
func readAvailableNodes(onlyHttpNodes bool) ([]string, error) {
res := []string{}
extraInfo := ""
if onlyHttpNodes {
extraInfo = string(OrchestratorExecutionHttpMode)
}
query := `
select
concat(hostname, ';', token) as node
from
node_health
where
last_seen_active > now() - interval ? second
and ? in (extra_info, '')
order by
hostname
`
err := db.QueryOrchestrator(query, sqlutils.Args(registrationPollSeconds*2, extraInfo), func(m sqlutils.RowMap) error {
res = append(res, m.GetString("node"))
return nil
})
if err != nil {
log.Errore(err)
}
return res, err
}
示例7: ReadRecentlyActiveClusterRecovery
// ReadRecentlyActiveClusterRecovery reads recently completed entries for a given cluster
func ReadRecentlyActiveClusterRecovery(clusterName string) ([]TopologyRecovery, error) {
whereClause := `
where
end_recovery > now() - interval 5 minute
and cluster_name=?`
return readRecoveries(whereClause, ``, sqlutils.Args(clusterName))
}
示例8: ReadActiveRecoveries
// ReadActiveRecoveries reads active recovery entry/audit entires from topology_recovery
func ReadActiveRecoveries() ([]TopologyRecovery, error) {
return readRecoveries(`
where
in_active_period=1
and end_recovery is null`,
``, sqlutils.Args())
}
示例9: ReadInActivePeriodClusterRecovery
// ReadInActivePeriodClusterRecovery reads recoveries (possibly complete!) that are in active period.
// (may be used to block further recoveries on this cluster)
func ReadInActivePeriodClusterRecovery(clusterName string) ([]TopologyRecovery, error) {
whereClause := `
where
in_active_period=1
and cluster_name=?`
return readRecoveries(whereClause, ``, sqlutils.Args(clusterName))
}
示例10: AcknowledgeInstanceRecoveries
// AcknowledgeInstanceRecoveries marks active recoveries for given instane as acknowledged.
// This also implied clearing their active period, which in turn enables further recoveries on those topologies
func AcknowledgeInstanceRecoveries(instanceKey *inst.InstanceKey, owner string, comment string) (countAcknowledgedEntries int64, err error) {
whereClause := `
hostname = ?
and port = ?
`
return acknowledgeRecoveries(owner, comment, false, whereClause, sqlutils.Args(instanceKey.Hostname, instanceKey.Port))
}
示例11: acknowledgeRecoveries
// acknowledgeRecoveries sets acknowledged* details and clears the in_active_period flags from a set of entries
func acknowledgeRecoveries(owner string, comment string, markEndRecovery bool, whereClause string, args []interface{}) (countAcknowledgedEntries int64, err error) {
additionalSet := ``
if markEndRecovery {
additionalSet = `
end_recovery=IFNULL(end_recovery, NOW()),
`
}
query := fmt.Sprintf(`
update topology_recovery set
in_active_period = 0,
end_active_period_unixtime = IF(end_active_period_unixtime = 0, UNIX_TIMESTAMP(), end_active_period_unixtime),
%s
acknowledged = 1,
acknowledged_at = NOW(),
acknowledged_by = ?,
acknowledge_comment = ?
where
acknowledged = 0
and
%s
`, additionalSet, whereClause)
args = append(sqlutils.Args(owner, comment), args...)
sqlResult, err := db.ExecOrchestrator(query, args...)
if err != nil {
return 0, log.Errore(err)
}
rows, err := sqlResult.RowsAffected()
return rows, log.Errore(err)
}
示例12: ReadLongRunningProcesses
// ReadLongRunningProcesses returns the list of current known long running processes of all instances
func ReadLongRunningProcesses(filter string) ([]Process, error) {
longRunningProcesses := []Process{}
if filter != "" {
filter = "%" + filter + "%"
} else {
filter = "%"
}
query := `
select
hostname,
port,
process_id,
process_started_at,
process_user,
process_host,
process_db,
process_command,
process_time_seconds,
process_state,
process_info
from
database_instance_long_running_queries
where
hostname like ?
or process_user like ?
or process_host like ?
or process_db like ?
or process_command like ?
or process_state like ?
or process_info like ?
order by
process_time_seconds desc
`
args := sqlutils.Args(filter, filter, filter, filter, filter, filter, filter)
err := db.QueryOrchestrator(query, args, func(m sqlutils.RowMap) error {
process := Process{}
process.InstanceHostname = m.GetString("hostname")
process.InstancePort = m.GetInt("port")
process.Id = m.GetInt64("process_id")
process.User = m.GetString("process_user")
process.Host = m.GetString("process_host")
process.Db = m.GetString("process_db")
process.Command = m.GetString("process_command")
process.Time = m.GetInt64("process_time_seconds")
process.State = m.GetString("process_state")
process.Info = m.GetString("process_info")
process.StartedAt = m.GetString("process_started_at")
longRunningProcesses = append(longRunningProcesses, process)
return nil
})
if err != nil {
log.Errore(err)
}
return longRunningProcesses, err
}
示例13: GetHostAttributesByAttribute
// GetHostAttributesByMatch
func GetHostAttributesByAttribute(attributeName string, valueMatch string) ([]HostAttributes, error) {
if valueMatch == "" {
valueMatch = ".?"
}
whereClause := ` where attribute_name = ? and attribute_value rlike ?`
return getHostAttributesByClause(whereClause, sqlutils.Args(attributeName, valueMatch))
}
示例14: ReadRecentlyActiveInstanceRecovery
// ReadRecentlyActiveInstanceRecovery reads recently completed entries for a given instance
func ReadRecentlyActiveInstanceRecovery(instanceKey *inst.InstanceKey) ([]TopologyRecovery, error) {
whereClause := `
where
end_recovery > now() - interval 5 minute
and
successor_hostname=? and successor_port=?`
return readRecoveries(whereClause, ``, sqlutils.Args(instanceKey.Hostname, instanceKey.Port))
}
示例15: ReadInActivePeriodSuccessorInstanceRecovery
// ReadInActivePeriodSuccessorInstanceRecovery reads completed recoveries for a given instance, where said instance
// was promoted as result, still in active period (may be used to block further recoveries should this instance die)
func ReadInActivePeriodSuccessorInstanceRecovery(instanceKey *inst.InstanceKey) ([]TopologyRecovery, error) {
whereClause := `
where
in_active_period=1
and
successor_hostname=? and successor_port=?`
return readRecoveries(whereClause, ``, sqlutils.Args(instanceKey.Hostname, instanceKey.Port))
}