From bb2c31e0e229920a2a7f2b3fd613aaa22bbff959 Mon Sep 17 00:00:00 2001 From: Aleksey Khorev Date: Fri, 18 Sep 2020 14:57:09 +0300 Subject: [PATCH] fix error import --- agent/onAgent.go | 13 +++--- agent/pool.go | 8 ++-- cmd/cmd_runner.go | 2 +- go.mod | 2 + go.sum | 6 +++ runner.go | 10 ++--- types.go | 102 +++++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 124 insertions(+), 19 deletions(-) diff --git a/agent/onAgent.go b/agent/onAgent.go index 08ea1dc..7ead23b 100644 --- a/agent/onAgent.go +++ b/agent/onAgent.go @@ -1,9 +1,8 @@ package agent import ( - agent2 "github.com/khorevaa/go-v8platform/agent" - agent "github.com/khorevaa/go-v8platform/agent/client" "github.com/khorevaa/go-v8platform/types" + agent "github.com/v8platform/agent" ) type ClientPool struct { @@ -21,7 +20,7 @@ type AgentPool struct { type RunningAgent struct { connectionString string - agent2.AgentModeOptions + //agent.AgentModeOptions // Признак запуска конфигуратора в режиме анета Running bool @@ -36,11 +35,11 @@ func (s RunningAgent) Stop() { } -func (s RunningAgent) Start() error { +func (s RunningAgent) Start() { - go func() { - - }() + //go func() { + // + //}() } diff --git a/agent/pool.go b/agent/pool.go index bd01d74..0bdf3a4 100644 --- a/agent/pool.go +++ b/agent/pool.go @@ -1,6 +1,6 @@ package agent -import agent "github.com/khorevaa/go-v8platform/agent/client" +import agent "github.com/v8platform/agent" type ClientID string @@ -12,9 +12,9 @@ type Pool struct { func (p *Pool) process() { - p.pool[id] = &Client{ - ID: id, - } + //p.pool[id] = &Client{ + // ID: id, + //} p.count++ diff --git a/cmd/cmd_runner.go b/cmd/cmd_runner.go index 9ca59cb..bff3381 100644 --- a/cmd/cmd_runner.go +++ b/cmd/cmd_runner.go @@ -2,7 +2,7 @@ package cmd import ( "context" - "github.com/khorevaa/go-v8platform/errors" + "github.com/v8platform/errors" //"github.com/khorevaa/go-v8platform/errors" "os" diff --git a/go.mod b/go.mod index 1428631..86c51ff 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,8 @@ go 1.12 require ( github.com/khorevaa/go-v8platform v0.0.0-20200604183936-0990660c2e4f github.com/stretchr/testify v1.6.1 + github.com/v8platform/agent v0.0.0-20200703051804-b06e6737a7b5 + github.com/v8platform/errors v0.1.0 github.com/v8platform/find v0.0.0-20200629131701-72a40bdf1034 github.com/v8platform/marshaler v0.0.0-20200630110446-ab0bd14c5414 golang.org/x/text v0.3.3 diff --git a/go.sum b/go.sum index ce4697d..1207f47 100644 --- a/go.sum +++ b/go.sum @@ -20,6 +20,10 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/v8platform/agent v0.0.0-20200703051804-b06e6737a7b5 h1:exdR2JPaLRuRvaLLyPzVHAZV7KkQGrblL2ch5J3Dkpg= +github.com/v8platform/agent v0.0.0-20200703051804-b06e6737a7b5/go.mod h1:fLdJkSja8K++qa7+Lw4RQBHsEdS18GcE2F2BlFK33Z4= +github.com/v8platform/errors v0.1.0 h1:7167okMmxBb76FA3+irT4LW9KTVura0vhMWnFDMHcZw= +github.com/v8platform/errors v0.1.0/go.mod h1:7tASRzzC2AeE0NrQaYT6qfGO2alI0hW91fpoC3lPbQA= github.com/v8platform/find v0.0.0-20200629131701-72a40bdf1034 h1:tUWtou0ZdFgxfiePSkO9uQGuN+GkrA4nEWDjOb/OqZ8= github.com/v8platform/find v0.0.0-20200629131701-72a40bdf1034/go.mod h1:tfhUIhAlIplptMrqi6I2+ygI4CIsbMwCR1SMQ/4tDC0= github.com/v8platform/marshaler v0.0.0-20200630110446-ab0bd14c5414 h1:ME4MvcuTion7r6lDWihTwgUnoFTzj47Kh4PLbtWegbc= @@ -27,6 +31,8 @@ github.com/v8platform/marshaler v0.0.0-20200630110446-ab0bd14c5414/go.mod h1:te7 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 h1:7KByu05hhLed2MO29w7p1XfZvZ13m8mub3shuVftRs0= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= diff --git a/runner.go b/runner.go index cf2db47..2dc9668 100644 --- a/runner.go +++ b/runner.go @@ -1,7 +1,7 @@ package runner import ( - "github.com/khorevaa/go-v8platform/errors" + "github.com/v8platform/errors" "github.com/v8platform/find" "github.com/v8platform/runner/cmd" "strings" @@ -209,14 +209,12 @@ func getOptions(opts ...interface{}) *Options { for _, opt := range opts { - switch opt.(type) { + switch o := opt.(type) { case Options: - userOptions, _ := opt.(Options) - return &userOptions + return &o case *Options: - userOptions, _ := opt.(*Options) - return userOptions + return o } } diff --git a/types.go b/types.go index 280ebc8..0207c7a 100644 --- a/types.go +++ b/types.go @@ -1,7 +1,23 @@ package runner +import "fmt" + +// +//type Params interface { +// Set(key, sep, value string) +// Append(v2 Params) +// Values() []Param +// StringValues() []string +// String() string +//} + +type Param interface { + Key() string + Sep() string + Value() string +} + type Infobase interface { - // Clear path Path() string // Возвращает // - /IBConnectionString <СтрокаПодключения> @@ -16,3 +32,87 @@ type Command interface { Check() error Values() []string } + +type Values struct { + keys []string + values map[string]Param +} + +func (v Values) Len() int { + return len(v.keys) +} + +type param struct { + key string + sep string + val string +} + +func (v param) Key() string { + return v.key +} +func (v param) Sep() string { + return v.sep +} +func (v param) Value() string { + return v.val +} + +type ValueSep string + +func NewValues() *Values { + return &Values{ + values: make(map[string]Param), + } +} + +const ( + SpaceSep ValueSep = " " + EqualSep ValueSep = "=" + NoSep ValueSep = "" +) + +func (v *Values) Values() []string { + + var str []string + + for _, value := range v.values { + str = append(str, fmt.Sprintf("%s%s", value.Sep(), value.Value())) + } + + return str +} + +func (v *Values) Set(key string, sep string, value string) { + + v.Map(param{ + key, sep, value, + }) + +} + +func (v *Values) Map(val Param) { + + key := val.Key() + + _, ok := v.values[key] + + if !ok { + v.keys = append(v.keys, key) + } + + v.values[key] = val + +} + +func (v *Values) GetMap() { + +} + +func (v *Values) Append(v2 Params) { + + //for _, s2 := range v2.Len() { + // v.Map(s2.key, s2.val) + //} + +}