diff --git a/agent/agent_runner.go b/agent/agent_runner.go deleted file mode 100644 index 36a8b2e..0000000 --- a/agent/agent_runner.go +++ /dev/null @@ -1,77 +0,0 @@ -package agent - -import ( - "context" - "os" - "os/exec" -) - -type Option func(r *AgentRunner) - -func WithContext(ctx context.Context) Option { - - return func(r *AgentRunner) { - r.ctx = ctx - } - -} - -type AgentRunner struct { - cmd *exec.Cmd - command string - args []string - env []string - ctx context.Context -} - -func (r *AgentRunner) Options(opts ...Option) { - - for _, opt := range opts { - opt(r) - } - -} - -func NewRunner(connection string, command string, args []string, opts ...Option) AgentRunner { - - cmd := AgentRunner{ - command: command, - args: args, - } - - cmd.Options(opts...) - - return cmd - -} - -func (runner AgentRunner) Run(signals <-chan os.Signal, ready chan<- struct{}) error { - - if runner.ctx != nil { - runner.cmd = exec.CommandContext(runner.ctx, runner.command, runner.args...) - } else { - runner.cmd = exec.Command(runner.command, runner.args...) - } - - err := runner.cmd.Start() - if err != nil { - return err - } - - close(ready) - - waitErr := make(chan error, 1) - - go func() { - waitErr <- runner.cmd.Wait() - }() - - for { - select { - case sig := <-signals: - runner.cmd.Process.Signal(sig) - case err := <-waitErr: - return err - } - } -} diff --git a/agent/onAgent.go b/agent/onAgent.go deleted file mode 100644 index b27af37..0000000 --- a/agent/onAgent.go +++ /dev/null @@ -1,47 +0,0 @@ -package agent - -import ( - agent "github.com/v8platform/agent" -) - -type ClientPool struct { - pool map[string]agent.Agent - OnConnect func(ConnectString string) - OnDisconnect func(ConnectString string) -} - -type AgentPool struct { - pool map[string]agent.Agent - OnCreate func(ConnectString string) - OnDisconnect func(ConnectString string) -} - -type RunningAgent struct { - connectionString string - - //agent.AgentModeOptions - - // Признак запуска конфигуратора в режиме анета - Running bool - - // Канал для остановки режима агента - stop chan struct{} -} - -func (s RunningAgent) Stop() { - - s.stop <- struct{}{} - -} - -func (s RunningAgent) Start() { - - //go func() { - // - //}() - -} - -//func RunOnAgent(where runner.Infobase, what runner.Command, opts ...interface{}) { -// -//} diff --git a/agent/pool.go b/agent/pool.go deleted file mode 100644 index 0bdf3a4..0000000 --- a/agent/pool.go +++ /dev/null @@ -1,51 +0,0 @@ -package agent - -import agent "github.com/v8platform/agent" - -type ClientID string - -type Pool struct { - pool map[ClientID]*Client - count int - maxPoolSize int -} - -func (p *Pool) process() { - - //p.pool[id] = &Client{ - // ID: id, - //} - - p.count++ - -} - -func (p *Pool) newClient(id ClientID) { - - p.pool[id] = &Client{ - ID: id, - } - - p.count++ - -} - -type Client struct { - ID ClientID // идентификатор строка подключения к базе - ready bool - client *agent.AgentClient -} - -func (c *Client) Start() error { - - c.ready = true - // TODO - return nil -} - -func (c *Client) Stop() error { - - c.client.Stop() - c.ready = false - return nil -}