本文整理汇总了Golang中github.com/percona/percona-agent/pct.NewSyncChan函数的典型用法代码示例。如果您正苦于以下问题:Golang NewSyncChan函数的具体用法?Golang NewSyncChan怎么用?Golang NewSyncChan使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewSyncChan函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewWaitTicker
func NewWaitTicker(atInterval uint) *WaitTicker {
wt := &WaitTicker{
atInterval: atInterval,
sync: pct.NewSyncChan(),
}
return wt
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:7,代码来源:wait.go
示例2: NewMockIntervalIter
func NewMockIntervalIter(intervalChan chan *qan.Interval) *MockIntervalIter {
iter := &MockIntervalIter{
intervalChan: make(chan *qan.Interval),
testIntervalChan: intervalChan,
sync: pct.NewSyncChan(),
}
return iter
}
开发者ID:huangzhiyong,项目名称:percona-agent,代码行数:8,代码来源:interval_iter.go
示例3: NewSender
func NewSender(logger *pct.Logger, client pct.WebsocketClient) *Sender {
s := &Sender{
logger: logger,
client: client,
sync: pct.NewSyncChan(),
status: pct.NewStatus([]string{"data-sender"}),
}
return s
}
开发者ID:huangzhiyong,项目名称:percona-agent,代码行数:9,代码来源:sender.go
示例4: NewEvenTicker
func NewEvenTicker(atInterval uint, sleep func(time.Duration)) *EvenTicker {
et := &EvenTicker{
atInterval: atInterval,
sleep: sleep,
watcher: make(map[chan time.Time]bool),
watcherMux: new(sync.Mutex),
sync: pct.NewSyncChan(),
}
return et
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:10,代码来源:ticker.go
示例5: NewIter
func NewIter(logger *pct.Logger, tickChan chan time.Time) *Iter {
iter := &Iter{
logger: logger,
tickChan: tickChan,
// --
intervalChan: make(chan *qan.Interval, 1),
sync: pct.NewSyncChan(),
}
return iter
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:10,代码来源:iter.go
示例6: NewIter
func NewIter(intervalChan chan *qan.Interval) *Iter {
iter := &Iter{
testIntervalChan: intervalChan,
// --
intervalChan: make(chan *qan.Interval, 1),
sync: pct.NewSyncChan(),
tickChan: make(chan time.Time),
calls: []string{},
}
return iter
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:11,代码来源:interval_iter.go
示例7: NewSender
func NewSender(logger *pct.Logger, client pct.WebsocketClient) *Sender {
s := &Sender{
logger: logger,
client: client,
sync: pct.NewSyncChan(),
status: pct.NewStatus([]string{"data-sender", "data-sender-last", "data-sender-1d"}),
lastStats: NewSenderStats(0),
dailyStats: NewSenderStats(24 * time.Hour),
}
return s
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:11,代码来源:sender.go
示例8: NewAggregator
func NewAggregator(logger *pct.Logger, interval int64, collectionChan chan *Collection, spool data.Spooler) *Aggregator {
a := &Aggregator{
logger: logger,
interval: interval,
collectionChan: collectionChan,
spool: spool,
// --
sync: pct.NewSyncChan(),
}
return a
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:11,代码来源:aggregator.go
示例9: NewFileIntervalIter
func NewFileIntervalIter(logger *pct.Logger, filename FilenameFunc, tickChan chan time.Time) *FileIntervalIter {
iter := &FileIntervalIter{
logger: logger,
filename: filename,
tickChan: tickChan,
// --
intervalChan: make(chan *Interval, 1),
running: false,
sync: pct.NewSyncChan(),
}
return iter
}
开发者ID:huangzhiyong,项目名称:percona-agent,代码行数:12,代码来源:interval.go
示例10: NewWebsocketClient
func NewWebsocketClient(logger *pct.Logger, api pct.APIConnector, link string) (*WebsocketClient, error) {
name := logger.Service()
c := &WebsocketClient{
logger: logger,
api: api,
link: link,
// --
conn: nil,
recvChan: make(chan *proto.Cmd, RECV_BUFFER_SIZE),
sendChan: make(chan *proto.Reply, SEND_BUFFER_SIZE),
connectChan: make(chan bool, 1),
errChan: make(chan error, 2),
backoff: pct.NewBackoff(5 * time.Minute),
sendSync: pct.NewSyncChan(),
recvSync: pct.NewSyncChan(),
mux: new(sync.Mutex),
name: name,
status: pct.NewStatus([]string{name, name + "-link"}),
}
return c, nil
}
开发者ID:huangzhiyong,项目名称:percona-agent,代码行数:21,代码来源:ws.go
示例11: NewMonitor
func NewMonitor(name string, config *Config, logger *pct.Logger, conn mysql.Connector) *Monitor {
m := &Monitor{
name: name,
config: config,
logger: logger,
conn: conn,
// --
sync: pct.NewSyncChan(),
status: pct.NewStatus([]string{name, name + "-mysql"}),
}
return m
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:12,代码来源:monitor.go
示例12: NewDiskvSpooler
func NewDiskvSpooler(logger *pct.Logger, dataDir string, hostname string) *DiskvSpooler {
s := &DiskvSpooler{
logger: logger,
dataDir: dataDir,
hostname: hostname,
// --
dataChan: make(chan *proto.Data, WRITE_BUFFER),
sync: pct.NewSyncChan(),
status: pct.NewStatus([]string{"data-spooler"}),
mux: new(sync.Mutex),
}
return s
}
开发者ID:huangzhiyong,项目名称:percona-agent,代码行数:13,代码来源:spooler.go
示例13: NewMonitor
func NewMonitor(logger *pct.Logger, mysqlConnFactory mysql.ConnectionFactory) mrms.Monitor {
m := &Monitor{
logger: logger,
mysqlConnFactory: mysqlConnFactory,
// --
mysqlInstances: make(map[string]*MysqlInstance),
// --
status: pct.NewStatus([]string{MONITOR_NAME}),
sync: pct.NewSyncChan(),
globalChan: make(chan string, 100),
}
return m
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:13,代码来源:monitor.go
示例14: NewMonitor
func NewMonitor(name string, config *Config, logger *pct.Logger) *Monitor {
m := &Monitor{
name: name,
config: config,
logger: logger,
// --
prevCPUval: make(map[string][]float64),
prevCPUsum: make(map[string]float64),
status: pct.NewStatus([]string{name}),
sync: pct.NewSyncChan(),
}
return m
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:13,代码来源:monitor.go
示例15: NewRealAnalyzer
func NewRealAnalyzer(logger *pct.Logger, config Config, iter IntervalIter, mysqlConn mysql.Connector, restartChan <-chan bool, worker Worker, clock ticker.Manager, spool data.Spooler) *RealAnalyzer {
name := logger.Service()
a := &RealAnalyzer{
logger: logger,
config: config,
iter: iter,
mysqlConn: mysqlConn,
restartChan: restartChan,
worker: worker,
clock: clock,
spool: spool,
// --
name: name,
mysqlConfiguredChan: make(chan bool, 1),
workerDoneChan: make(chan *Interval, 1),
status: pct.NewStatus([]string{name, name + "-last-interval", name + "-next-interval"}),
runSync: pct.NewSyncChan(),
configureMySQLSync: pct.NewSyncChan(),
mux: &sync.RWMutex{},
}
return a
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:22,代码来源:analyzer.go
示例16: NewDiskvSpooler
func NewDiskvSpooler(logger *pct.Logger, dataDir, trashDir, hostname string, limits proto.DataSpoolLimits) *DiskvSpooler {
s := &DiskvSpooler{
logger: logger,
dataDir: dataDir,
trashDir: trashDir,
hostname: hostname,
limits: limits,
// --
dataChan: make(chan *proto.Data, DEFAULT_DATA_MAX_FILES),
sync: pct.NewSyncChan(),
status: pct.NewStatus([]string{"data-spooler", "data-spooler-count", "data-spooler-size", "data-spooler-oldest"}),
mux: new(sync.Mutex),
fileSize: make(map[string]int),
}
return s
}
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:16,代码来源:spooler.go
示例17: NewManager
func NewManager(logger *pct.Logger, mysqlFactory mysql.ConnectionFactory, clock ticker.Manager, iterFactory IntervalIterFactory, workerFactory WorkerFactory, spool data.Spooler, im *instance.Repo) *Manager {
m := &Manager{
logger: logger,
mysqlFactory: mysqlFactory,
clock: clock,
iterFactory: iterFactory,
workerFactory: workerFactory,
spool: spool,
im: im,
// --
mux: new(sync.RWMutex),
tickChan: make(chan time.Time),
workers: make(map[Worker]*Interval),
workersMux: new(sync.RWMutex),
workerDoneChan: make(chan Worker, 2),
status: pct.NewStatus([]string{"qan", "qan-log-parser", "qan-last-interval", "qan-next-interval"}),
sync: pct.NewSyncChan(),
oldSlowLogs: make(map[string]int),
}
return m
}
开发者ID:huangzhiyong,项目名称:percona-agent,代码行数:21,代码来源:manager.go
示例18: Run
// percona-agent:@goroutine[0]
func (agent *Agent) Run() error {
logger := agent.logger
logger.Debug("Run:call")
defer logger.Debug("Run:return")
// Start client goroutines for sending/receving cmd/reply via channels
// so we can do non-blocking send/recv. This only needs to be done once.
// The chans are buffered, so they work for awhile if not connected.
client := agent.client
client.Start()
cmdChan := client.RecvChan()
connected := false
go agent.connect()
/*
* Start the status and cmd handlers. Most messages must be serialized because,
* for example, handling start-service and stop-service at the same
* time would cause weird problems. The cmdChan serializes messages,
* so it's "first come, first serve" (i.e. fifo). Concurrency has
* consequences: e.g. if user1 sends a start-service and it succeeds
* and user2 send the same start-service, user2 will get a ServiceIsRunningError.
* Status requests are handled concurrently so the user can always see what
* the agent is doing even if it's busy processing commands.
*/
agent.cmdHandlerSync = pct.NewSyncChan()
go agent.cmdHandler()
agent.statusHandlerSync = pct.NewSyncChan()
go agent.statusHandler()
// Allow those ^ goroutines to crash up to MAX_ERRORS. Any more and it's
// probably a code bug rather than bad input, network error, etc.
cmdHandlerErrors := 0
statusHandlerErrors := 0
// Send Pong to API to keep cmd ws open or detect if API end is closed.
// https://jira.percona.com/browse/PCT-765
agent.keepalive = time.NewTicker(time.Duration(agent.config.Keepalive) * time.Second)
logger.Info("Started version: " + VERSION)
for {
logger.Debug("idle")
agent.status.Update("agent", "Idle")
select {
case cmd := <-cmdChan: // from API
if cmd.Cmd == "Abort" {
panic(cmd)
}
switch cmd.Cmd {
case "Restart":
logger.Debug("cmd:restart")
agent.status.UpdateRe("agent", "Restarting", cmd)
// Secure the start-lock file. This lets us start our self but
// wait until this process has exited, at which time the start-lock
// is removed and the 2nd self continues starting.
if err := pct.MakeStartLock(); err != nil {
agent.reply(cmd.Reply(nil, err))
continue
}
// Start our self with the same args this process was started with.
cwd, err := os.Getwd()
if err != nil {
agent.reply(cmd.Reply(nil, err))
}
comment := fmt.Sprintf(
"This script was created by percona-agent in response to this Restart command:\n"+
"# %s\n"+
"# It is safe to delete.", cmd)
sh := fmt.Sprintf("#!/bin/sh\n# %s\ncd %s\n%s %s >> %s/percona-agent.log 2>&1 &\n",
comment,
cwd,
os.Args[0],
strings.Join(os.Args[1:len(os.Args)], " "),
pct.Basedir.Path(),
)
startScript := pct.Basedir.File("start-script")
if err := ioutil.WriteFile(startScript, []byte(sh), os.FileMode(0754)); err != nil {
agent.reply(cmd.Reply(nil, err))
}
logger.Debug("Restart:sh")
self := pctCmd.Factory.Make(startScript)
output, err := self.Run()
agent.reply(cmd.Reply(output, err))
logger.Debug("Restart:done")
return nil
case "Stop":
logger.Debug("cmd:stop")
logger.Info("Stopping", cmd)
agent.status.UpdateRe("agent", "Stopping", cmd)
agent.stop()
agent.reply(cmd.Reply(nil))
logger.Info("Stopped", cmd)
agent.status.UpdateRe("agent", "Stopped", cmd)
return nil
case "Status":
//.........这里部分代码省略.........
开发者ID:hg3rdrock,项目名称:percona-agent,代码行数:101,代码来源:agent.go
注:本文中的github.com/percona/percona-agent/pct.NewSyncChan函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论