From 63568449763ec46ef9800b6efd193db3796d7bdc Mon Sep 17 00:00:00 2001 From: lbbniu Date: Wed, 26 Apr 2023 12:24:31 +0800 Subject: [PATCH] perf(protocol): update tars base protocol --- tars/protocol/res/adminf/AdminF.tars.go | 188 +- tars/protocol/res/basef/BaseF.go | 4 +- tars/protocol/res/configf/Config.tars.go | 1230 ++------------ tars/protocol/res/configf/ConfigF.go | 2 +- tars/protocol/res/endpointf/EndpointF.go | 2 +- tars/protocol/res/logf/Log.tars.go | 237 +-- tars/protocol/res/logf/LogF.go | 2 +- tars/protocol/res/nodef/NodeF.go | 2 +- tars/protocol/res/nodef/ServerF.tars.go | 206 +-- tars/protocol/res/notifyf/Notify.tars.go | 372 +--- tars/protocol/res/notifyf/NotifyF.go | 2 +- tars/protocol/res/propertyf/PropertyF.go | 2 +- tars/protocol/res/propertyf/PropertyF.tars.go | 169 +- tars/protocol/res/queryf/QueryF.tars.go | 1509 +++-------------- tars/protocol/res/requestf/RequestF.go | 2 +- tars/protocol/res/statf/StatF.go | 2 +- tars/protocol/res/statf/StatF.tars.go | 278 +-- 17 files changed, 614 insertions(+), 3595 deletions(-) diff --git a/tars/protocol/res/adminf/AdminF.tars.go b/tars/protocol/res/adminf/AdminF.tars.go index 57164a40..a5581238 100644 --- a/tars/protocol/res/adminf/AdminF.tars.go +++ b/tars/protocol/res/adminf/AdminF.tars.go @@ -1,5 +1,5 @@ // Package adminf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from AdminF.tars package adminf @@ -14,6 +14,7 @@ import ( "github.com/TarsCloud/TarsGo/tars/protocol/res/requestf" "github.com/TarsCloud/TarsGo/tars/protocol/tup" "github.com/TarsCloud/TarsGo/tars/util/current" + "github.com/TarsCloud/TarsGo/tars/util/endpoint" "github.com/TarsCloud/TarsGo/tars/util/tools" "unsafe" ) @@ -31,56 +32,29 @@ type AdminF struct { servant m.Servant } -// Shutdown is the proxy function for the method defined in the tars file, with the context -func (obj *AdminF) Shutdown(opts ...map[string]string) (err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() +// SetServant sets servant for the service. +func (obj *AdminF) SetServant(servant m.Servant) { + obj.servant = servant +} - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() +// TarsSetTimeout sets the timeout for the servant which is in ms. +func (obj *AdminF) TarsSetTimeout(timeout int) { + obj.servant.TarsSetTimeout(timeout) +} - err = obj.servant.TarsInvoke(tarsCtx, 0, "shutdown", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return err - } +// TarsSetProtocol sets the protocol for the servant. +func (obj *AdminF) TarsSetProtocol(p m.Protocol) { + obj.servant.TarsSetProtocol(p) +} - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return nil +// Endpoints returns all active endpoint.Endpoint +func (obj *AdminF) Endpoints() []*endpoint.Endpoint { + return obj.servant.Endpoints() +} + +// Shutdown is the proxy function for the method defined in the tars file, with the context +func (obj *AdminF) Shutdown(opts ...map[string]string) error { + return obj.ShutdownWithContext(context.Background(), opts...) } // ShutdownWithContext is the proxy function for the method defined in the tars file, with the context @@ -156,27 +130,6 @@ func (obj *AdminF) ShutdownOneWayWithContext(tarsCtx context.Context, opts ...ma return err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty @@ -184,65 +137,8 @@ func (obj *AdminF) ShutdownOneWayWithContext(tarsCtx context.Context, opts ...ma } // Notify is the proxy function for the method defined in the tars file, with the context -func (obj *AdminF) Notify(command string, opts ...map[string]string) (ret string, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(command, 1) - if err != nil { - return ret, err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "notify", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadString(&ret, 0, true) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil +func (obj *AdminF) Notify(command string, opts ...map[string]string) (string, error) { + return obj.NotifyWithContext(context.Background(), command, opts...) } // NotifyWithContext is the proxy function for the method defined in the tars file, with the context @@ -334,48 +230,12 @@ func (obj *AdminF) NotifyOneWayWithContext(tarsCtx context.Context, command stri return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// SetServant sets servant for the service. -func (obj *AdminF) SetServant(servant m.Servant) { - obj.servant = servant -} - -// TarsSetTimeout sets the timeout for the servant which is in ms. -func (obj *AdminF) TarsSetTimeout(timeout int) { - obj.servant.TarsSetTimeout(timeout) -} - -// TarsSetProtocol sets the protocol for the servant. -func (obj *AdminF) TarsSetProtocol(p m.Protocol) { - obj.servant.TarsSetProtocol(p) -} - type AdminFServant interface { Shutdown() (err error) Notify(command string) (ret string, err error) diff --git a/tars/protocol/res/basef/BaseF.go b/tars/protocol/res/basef/BaseF.go index f8eef2d5..07a699b0 100644 --- a/tars/protocol/res/basef/BaseF.go +++ b/tars/protocol/res/basef/BaseF.go @@ -1,5 +1,5 @@ // Package basef comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from BaseF.tars package basef @@ -13,7 +13,7 @@ import ( var _ = fmt.Errorf var _ = codec.FromInt8 -//const as define in tars file +// const as define in tars file const ( TARSVERSION int16 = 0x01 TUPVERSION int16 = 0x03 diff --git a/tars/protocol/res/configf/Config.tars.go b/tars/protocol/res/configf/Config.tars.go index 4fcf25a4..f58a7e9f 100644 --- a/tars/protocol/res/configf/Config.tars.go +++ b/tars/protocol/res/configf/Config.tars.go @@ -1,5 +1,5 @@ // Package configf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from ConfigF.tars package configf @@ -14,6 +14,7 @@ import ( "github.com/TarsCloud/TarsGo/tars/protocol/res/requestf" "github.com/TarsCloud/TarsGo/tars/protocol/tup" "github.com/TarsCloud/TarsGo/tars/util/current" + "github.com/TarsCloud/TarsGo/tars/util/endpoint" "github.com/TarsCloud/TarsGo/tars/util/tools" "unsafe" ) @@ -31,8 +32,33 @@ type Config struct { servant m.Servant } +// SetServant sets servant for the service. +func (obj *Config) SetServant(servant m.Servant) { + obj.servant = servant +} + +// TarsSetTimeout sets the timeout for the servant which is in ms. +func (obj *Config) TarsSetTimeout(timeout int) { + obj.servant.TarsSetTimeout(timeout) +} + +// TarsSetProtocol sets the protocol for the servant. +func (obj *Config) TarsSetProtocol(p m.Protocol) { + obj.servant.TarsSetProtocol(p) +} + +// Endpoints returns all active endpoint.Endpoint +func (obj *Config) Endpoints() []*endpoint.Endpoint { + return obj.servant.Endpoints() +} + // ListConfig is the proxy function for the method defined in the tars file, with the context -func (obj *Config) ListConfig(app string, server string, vf *[]string, opts ...map[string]string) (ret int32, err error) { +func (obj *Config) ListConfig(app string, server string, vf *[]string, opts ...map[string]string) (int32, error) { + return obj.ListConfigWithContext(context.Background(), app, server, vf, opts...) +} + +// ListConfigWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) ListConfigWithContext(tarsCtx context.Context, app string, server string, vf *[]string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -76,9 +102,8 @@ func (obj *Config) ListConfig(app string, server string, vf *[]string, opts ...m contextMap = opts[0] statusMap = opts[1] } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() + tarsResp := new(requestf.ResponsePacket) err = obj.servant.TarsInvoke(tarsCtx, 0, "ListConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err @@ -151,8 +176,8 @@ func (obj *Config) ListConfig(app string, server string, vf *[]string, opts ...m return ret, nil } -// ListConfigWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) ListConfigWithContext(tarsCtx context.Context, app string, server string, vf *[]string, opts ...map[string]string) (ret int32, err error) { +// ListConfigOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) ListConfigOneWayWithContext(tarsCtx context.Context, app string, server string, vf *[]string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -198,80 +223,24 @@ func (obj *Config) ListConfigWithContext(tarsCtx context.Context, app string, se } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 0, "ListConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - _, ty, err = readBuf.SkipToNoCheck(3, true) + err = obj.servant.TarsInvoke(tarsCtx, 1, "ListConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *vf = make([]string, length) - for i1, e1 := int32(0), length; i1 < e1; i1++ { - - err = readBuf.ReadString(&(*vf)[i1], 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// ListConfigOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) ListConfigOneWayWithContext(tarsCtx context.Context, app string, server string, vf *[]string, opts ...map[string]string) (ret int32, err error) { +// LoadConfig is the proxy function for the method defined in the tars file, with the context +func (obj *Config) LoadConfig(app string, server string, filename string, config *string, opts ...map[string]string) (int32, error) { + return obj.LoadConfigWithContext(context.Background(), app, server, filename, config, opts...) +} + +// LoadConfigWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) LoadConfigWithContext(tarsCtx context.Context, app string, server string, filename string, config *string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -288,25 +257,16 @@ func (obj *Config) ListConfigOneWayWithContext(tarsCtx context.Context, app stri return ret, err } - err = buf.WriteHead(codec.LIST, 3) + err = buf.WriteString(filename, 3) if err != nil { return ret, err } - err = buf.WriteInt32(int32(len(*vf)), 0) + err = buf.WriteString(*config, 4) if err != nil { return ret, err } - for _, v := range *vf { - - err = buf.WriteString(v, 0) - if err != nil { - return ret, err - } - - } - var statusMap map[string]string var contextMap map[string]string if len(opts) == 1 { @@ -317,7 +277,18 @@ func (obj *Config) ListConfigOneWayWithContext(tarsCtx context.Context, app stri } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "ListConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) + err = obj.servant.TarsInvoke(tarsCtx, 0, "loadConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) + if err != nil { + return ret, err + } + + readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) + err = readBuf.ReadInt32(&ret, 0, true) + if err != nil { + return ret, err + } + + err = readBuf.ReadString(&(*config), 4, true) if err != nil { return ret, err } @@ -349,8 +320,8 @@ func (obj *Config) ListConfigOneWayWithContext(tarsCtx context.Context, app stri return ret, nil } -// LoadConfig is the proxy function for the method defined in the tars file, with the context -func (obj *Config) LoadConfig(app string, server string, filename string, config *string, opts ...map[string]string) (ret int32, err error) { +// LoadConfigOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) LoadConfigOneWayWithContext(tarsCtx context.Context, app string, server string, filename string, config *string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -385,71 +356,43 @@ func (obj *Config) LoadConfig(app string, server string, filename string, config contextMap = opts[0] statusMap = opts[1] } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "loadConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - err = readBuf.ReadString(&(*config), 4, true) + tarsResp := new(requestf.ResponsePacket) + err = obj.servant.TarsInvoke(tarsCtx, 1, "loadConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// LoadConfigWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) LoadConfigWithContext(tarsCtx context.Context, app string, server string, filename string, config *string, opts ...map[string]string) (ret int32, err error) { +// LoadConfigByHost is the proxy function for the method defined in the tars file, with the context +func (obj *Config) LoadConfigByHost(appServerName string, filename string, host string, config *string, opts ...map[string]string) (int32, error) { + return obj.LoadConfigByHostWithContext(context.Background(), appServerName, filename, host, config, opts...) +} + +// LoadConfigByHostWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) LoadConfigByHostWithContext(tarsCtx context.Context, appServerName string, filename string, host string, config *string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool ty byte ) buf := codec.NewBuffer() - err = buf.WriteString(app, 1) + err = buf.WriteString(appServerName, 1) if err != nil { return ret, err } - err = buf.WriteString(server, 2) + err = buf.WriteString(filename, 2) if err != nil { return ret, err } - err = buf.WriteString(filename, 3) + err = buf.WriteString(host, 3) if err != nil { return ret, err } @@ -469,7 +412,7 @@ func (obj *Config) LoadConfigWithContext(tarsCtx context.Context, app string, se } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 0, "loadConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) + err = obj.servant.TarsInvoke(tarsCtx, 0, "loadConfigByHost", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } @@ -512,25 +455,25 @@ func (obj *Config) LoadConfigWithContext(tarsCtx context.Context, app string, se return ret, nil } -// LoadConfigOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) LoadConfigOneWayWithContext(tarsCtx context.Context, app string, server string, filename string, config *string, opts ...map[string]string) (ret int32, err error) { +// LoadConfigByHostOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) LoadConfigByHostOneWayWithContext(tarsCtx context.Context, appServerName string, filename string, host string, config *string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool ty byte ) buf := codec.NewBuffer() - err = buf.WriteString(app, 1) + err = buf.WriteString(appServerName, 1) if err != nil { return ret, err } - err = buf.WriteString(server, 2) + err = buf.WriteString(filename, 2) if err != nil { return ret, err } - err = buf.WriteString(filename, 3) + err = buf.WriteString(host, 3) if err != nil { return ret, err } @@ -550,40 +493,24 @@ func (obj *Config) LoadConfigOneWayWithContext(tarsCtx context.Context, app stri } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "loadConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) + err = obj.servant.TarsInvoke(tarsCtx, 1, "loadConfigByHost", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// LoadConfigByHost is the proxy function for the method defined in the tars file, with the context -func (obj *Config) LoadConfigByHost(appServerName string, filename string, host string, config *string, opts ...map[string]string) (ret int32, err error) { +// CheckConfig is the proxy function for the method defined in the tars file, with the context +func (obj *Config) CheckConfig(appServerName string, filename string, host string, result *string, opts ...map[string]string) (int32, error) { + return obj.CheckConfigWithContext(context.Background(), appServerName, filename, host, result, opts...) +} + +// CheckConfigWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) CheckConfigWithContext(tarsCtx context.Context, appServerName string, filename string, host string, result *string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -605,7 +532,7 @@ func (obj *Config) LoadConfigByHost(appServerName string, filename string, host return ret, err } - err = buf.WriteString(*config, 4) + err = buf.WriteString(*result, 4) if err != nil { return ret, err } @@ -618,10 +545,9 @@ func (obj *Config) LoadConfigByHost(appServerName string, filename string, host contextMap = opts[0] statusMap = opts[1] } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - err = obj.servant.TarsInvoke(tarsCtx, 0, "loadConfigByHost", buf.ToBytes(), statusMap, contextMap, tarsResp) + tarsResp := new(requestf.ResponsePacket) + err = obj.servant.TarsInvoke(tarsCtx, 0, "checkConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } @@ -632,7 +558,7 @@ func (obj *Config) LoadConfigByHost(appServerName string, filename string, host return ret, err } - err = readBuf.ReadString(&(*config), 4, true) + err = readBuf.ReadString(&(*result), 4, true) if err != nil { return ret, err } @@ -664,8 +590,8 @@ func (obj *Config) LoadConfigByHost(appServerName string, filename string, host return ret, nil } -// LoadConfigByHostWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) LoadConfigByHostWithContext(tarsCtx context.Context, appServerName string, filename string, host string, config *string, opts ...map[string]string) (ret int32, err error) { +// CheckConfigOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) CheckConfigOneWayWithContext(tarsCtx context.Context, appServerName string, filename string, host string, result *string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -687,7 +613,7 @@ func (obj *Config) LoadConfigByHostWithContext(tarsCtx context.Context, appServe return ret, err } - err = buf.WriteString(*config, 4) + err = buf.WriteString(*result, 4) if err != nil { return ret, err } @@ -702,481 +628,36 @@ func (obj *Config) LoadConfigByHostWithContext(tarsCtx context.Context, appServe } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 0, "loadConfigByHost", buf.ToBytes(), statusMap, contextMap, tarsResp) + err = obj.servant.TarsInvoke(tarsCtx, 1, "checkConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) + _ = length + _ = have + _ = ty + return ret, nil +} + +// ListConfigByInfo is the proxy function for the method defined in the tars file, with the context +func (obj *Config) ListConfigByInfo(configInfo *ConfigInfo, vf *[]string, opts ...map[string]string) (int32, error) { + return obj.ListConfigByInfoWithContext(context.Background(), configInfo, vf, opts...) +} + +// ListConfigByInfoWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) ListConfigByInfoWithContext(tarsCtx context.Context, configInfo *ConfigInfo, vf *[]string, opts ...map[string]string) (ret int32, err error) { + var ( + length int32 + have bool + ty byte + ) + buf := codec.NewBuffer() + err = configInfo.WriteBlock(buf, 1) if err != nil { return ret, err } - err = readBuf.ReadString(&(*config), 4, true) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// LoadConfigByHostOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) LoadConfigByHostOneWayWithContext(tarsCtx context.Context, appServerName string, filename string, host string, config *string, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(appServerName, 1) - if err != nil { - return ret, err - } - - err = buf.WriteString(filename, 2) - if err != nil { - return ret, err - } - - err = buf.WriteString(host, 3) - if err != nil { - return ret, err - } - - err = buf.WriteString(*config, 4) - if err != nil { - return ret, err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - - tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "loadConfigByHost", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// CheckConfig is the proxy function for the method defined in the tars file, with the context -func (obj *Config) CheckConfig(appServerName string, filename string, host string, result *string, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(appServerName, 1) - if err != nil { - return ret, err - } - - err = buf.WriteString(filename, 2) - if err != nil { - return ret, err - } - - err = buf.WriteString(host, 3) - if err != nil { - return ret, err - } - - err = buf.WriteString(*result, 4) - if err != nil { - return ret, err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "checkConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - err = readBuf.ReadString(&(*result), 4, true) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// CheckConfigWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) CheckConfigWithContext(tarsCtx context.Context, appServerName string, filename string, host string, result *string, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(appServerName, 1) - if err != nil { - return ret, err - } - - err = buf.WriteString(filename, 2) - if err != nil { - return ret, err - } - - err = buf.WriteString(host, 3) - if err != nil { - return ret, err - } - - err = buf.WriteString(*result, 4) - if err != nil { - return ret, err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - - tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 0, "checkConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - err = readBuf.ReadString(&(*result), 4, true) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// CheckConfigOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) CheckConfigOneWayWithContext(tarsCtx context.Context, appServerName string, filename string, host string, result *string, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(appServerName, 1) - if err != nil { - return ret, err - } - - err = buf.WriteString(filename, 2) - if err != nil { - return ret, err - } - - err = buf.WriteString(host, 3) - if err != nil { - return ret, err - } - - err = buf.WriteString(*result, 4) - if err != nil { - return ret, err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - - tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "checkConfig", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// ListConfigByInfo is the proxy function for the method defined in the tars file, with the context -func (obj *Config) ListConfigByInfo(configInfo *ConfigInfo, vf *[]string, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = configInfo.WriteBlock(buf, 1) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 2) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*vf)), 0) - if err != nil { - return ret, err - } - - for _, v := range *vf { - - err = buf.WriteString(v, 0) - if err != nil { - return ret, err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "ListConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - _, ty, err = readBuf.SkipToNoCheck(2, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *vf = make([]string, length) - for i2, e2 := int32(0), length; i2 < e2; i2++ { - - err = readBuf.ReadString(&(*vf)[i2], 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// ListConfigByInfoWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) ListConfigByInfoWithContext(tarsCtx context.Context, configInfo *ConfigInfo, vf *[]string, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = configInfo.WriteBlock(buf, 1) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 2) + err = buf.WriteHead(codec.LIST, 2) if err != nil { return ret, err } @@ -1228,9 +709,9 @@ func (obj *Config) ListConfigByInfoWithContext(tarsCtx context.Context, configIn } *vf = make([]string, length) - for i3, e3 := int32(0), length; i3 < e3; i3++ { + for i1, e1 := int32(0), length; i1 < e1; i1++ { - err = readBuf.ReadString(&(*vf)[i3], 0, false) + err = readBuf.ReadString(&(*vf)[i1], 0, false) if err != nil { return ret, err } @@ -1238,233 +719,16 @@ func (obj *Config) ListConfigByInfoWithContext(tarsCtx context.Context, configIn } } else if ty == codec.SimpleList { err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// ListConfigByInfoOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) ListConfigByInfoOneWayWithContext(tarsCtx context.Context, configInfo *ConfigInfo, vf *[]string, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = configInfo.WriteBlock(buf, 1) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 2) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*vf)), 0) - if err != nil { - return ret, err - } - - for _, v := range *vf { - - err = buf.WriteString(v, 0) - if err != nil { - return ret, err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - - tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "ListConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// LoadConfigByInfo is the proxy function for the method defined in the tars file, with the context -func (obj *Config) LoadConfigByInfo(configInfo *ConfigInfo, config *string, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = configInfo.WriteBlock(buf, 1) - if err != nil { - return ret, err - } - - err = buf.WriteString(*config, 2) - if err != nil { - return ret, err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "loadConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - err = readBuf.ReadString(&(*config), 2, true) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// LoadConfigByInfoWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) LoadConfigByInfoWithContext(tarsCtx context.Context, configInfo *ConfigInfo, config *string, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = configInfo.WriteBlock(buf, 1) - if err != nil { - return ret, err - } - - err = buf.WriteString(*config, 2) - if err != nil { - return ret, err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - - tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 0, "loadConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } + if err != nil { + return ret, err + } - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } + } else { + err = fmt.Errorf("require vector, but not") + if err != nil { + return ret, err + } - err = readBuf.ReadString(&(*config), 2, true) - if err != nil { - return ret, err } if len(opts) == 1 { @@ -1494,8 +758,8 @@ func (obj *Config) LoadConfigByInfoWithContext(tarsCtx context.Context, configIn return ret, nil } -// LoadConfigByInfoOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) LoadConfigByInfoOneWayWithContext(tarsCtx context.Context, configInfo *ConfigInfo, config *string, opts ...map[string]string) (ret int32, err error) { +// ListConfigByInfoOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) ListConfigByInfoOneWayWithContext(tarsCtx context.Context, configInfo *ConfigInfo, vf *[]string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -1507,11 +771,25 @@ func (obj *Config) LoadConfigByInfoOneWayWithContext(tarsCtx context.Context, co return ret, err } - err = buf.WriteString(*config, 2) + err = buf.WriteHead(codec.LIST, 2) + if err != nil { + return ret, err + } + + err = buf.WriteInt32(int32(len(*vf)), 0) if err != nil { return ret, err } + for _, v := range *vf { + + err = buf.WriteString(v, 0) + if err != nil { + return ret, err + } + + } + var statusMap map[string]string var contextMap map[string]string if len(opts) == 1 { @@ -1522,40 +800,24 @@ func (obj *Config) LoadConfigByInfoOneWayWithContext(tarsCtx context.Context, co } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "loadConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) + err = obj.servant.TarsInvoke(tarsCtx, 1, "ListConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// CheckConfigByInfo is the proxy function for the method defined in the tars file, with the context -func (obj *Config) CheckConfigByInfo(configInfo *ConfigInfo, result *string, opts ...map[string]string) (ret int32, err error) { +// LoadConfigByInfo is the proxy function for the method defined in the tars file, with the context +func (obj *Config) LoadConfigByInfo(configInfo *ConfigInfo, config *string, opts ...map[string]string) (int32, error) { + return obj.LoadConfigByInfoWithContext(context.Background(), configInfo, config, opts...) +} + +// LoadConfigByInfoWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) LoadConfigByInfoWithContext(tarsCtx context.Context, configInfo *ConfigInfo, config *string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -1567,7 +829,7 @@ func (obj *Config) CheckConfigByInfo(configInfo *ConfigInfo, result *string, opt return ret, err } - err = buf.WriteString(*result, 2) + err = buf.WriteString(*config, 2) if err != nil { return ret, err } @@ -1580,10 +842,9 @@ func (obj *Config) CheckConfigByInfo(configInfo *ConfigInfo, result *string, opt contextMap = opts[0] statusMap = opts[1] } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - err = obj.servant.TarsInvoke(tarsCtx, 0, "checkConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) + tarsResp := new(requestf.ResponsePacket) + err = obj.servant.TarsInvoke(tarsCtx, 0, "loadConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } @@ -1594,7 +855,7 @@ func (obj *Config) CheckConfigByInfo(configInfo *ConfigInfo, result *string, opt return ret, err } - err = readBuf.ReadString(&(*result), 2, true) + err = readBuf.ReadString(&(*config), 2, true) if err != nil { return ret, err } @@ -1626,8 +887,8 @@ func (obj *Config) CheckConfigByInfo(configInfo *ConfigInfo, result *string, opt return ret, nil } -// CheckConfigByInfoWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) CheckConfigByInfoWithContext(tarsCtx context.Context, configInfo *ConfigInfo, result *string, opts ...map[string]string) (ret int32, err error) { +// LoadConfigByInfoOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) LoadConfigByInfoOneWayWithContext(tarsCtx context.Context, configInfo *ConfigInfo, config *string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -1639,7 +900,7 @@ func (obj *Config) CheckConfigByInfoWithContext(tarsCtx context.Context, configI return ret, err } - err = buf.WriteString(*result, 2) + err = buf.WriteString(*config, 2) if err != nil { return ret, err } @@ -1654,51 +915,24 @@ func (obj *Config) CheckConfigByInfoWithContext(tarsCtx context.Context, configI } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 0, "checkConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - err = readBuf.ReadString(&(*result), 2, true) + err = obj.servant.TarsInvoke(tarsCtx, 1, "loadConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// CheckConfigByInfoOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *Config) CheckConfigByInfoOneWayWithContext(tarsCtx context.Context, configInfo *ConfigInfo, result *string, opts ...map[string]string) (ret int32, err error) { +// CheckConfigByInfo is the proxy function for the method defined in the tars file, with the context +func (obj *Config) CheckConfigByInfo(configInfo *ConfigInfo, result *string, opts ...map[string]string) (int32, error) { + return obj.CheckConfigByInfoWithContext(context.Background(), configInfo, result, opts...) +} + +// CheckConfigByInfoWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) CheckConfigByInfoWithContext(tarsCtx context.Context, configInfo *ConfigInfo, result *string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -1725,7 +959,18 @@ func (obj *Config) CheckConfigByInfoOneWayWithContext(tarsCtx context.Context, c } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "checkConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) + err = obj.servant.TarsInvoke(tarsCtx, 0, "checkConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) + if err != nil { + return ret, err + } + + readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) + err = readBuf.ReadInt32(&ret, 0, true) + if err != nil { + return ret, err + } + + err = readBuf.ReadString(&(*result), 2, true) if err != nil { return ret, err } @@ -1757,8 +1002,8 @@ func (obj *Config) CheckConfigByInfoOneWayWithContext(tarsCtx context.Context, c return ret, nil } -// ListAllConfigByInfo is the proxy function for the method defined in the tars file, with the context -func (obj *Config) ListAllConfigByInfo(configInfo *GetConfigListInfo, vf *[]string, opts ...map[string]string) (ret int32, err error) { +// CheckConfigByInfoOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *Config) CheckConfigByInfoOneWayWithContext(tarsCtx context.Context, configInfo *ConfigInfo, result *string, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -1770,25 +1015,11 @@ func (obj *Config) ListAllConfigByInfo(configInfo *GetConfigListInfo, vf *[]stri return ret, err } - err = buf.WriteHead(codec.LIST, 2) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*vf)), 0) + err = buf.WriteString(*result, 2) if err != nil { return ret, err } - for _, v := range *vf { - - err = buf.WriteString(v, 0) - if err != nil { - return ret, err - } - - } - var statusMap map[string]string var contextMap map[string]string if len(opts) == 1 { @@ -1797,81 +1028,24 @@ func (obj *Config) ListAllConfigByInfo(configInfo *GetConfigListInfo, vf *[]stri contextMap = opts[0] statusMap = opts[1] } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "ListAllConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - _, ty, err = readBuf.SkipToNoCheck(2, true) + tarsResp := new(requestf.ResponsePacket) + err = obj.servant.TarsInvoke(tarsCtx, 1, "checkConfigByInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *vf = make([]string, length) - for i4, e4 := int32(0), length; i4 < e4; i4++ { - - err = readBuf.ReadString(&(*vf)[i4], 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } +// ListAllConfigByInfo is the proxy function for the method defined in the tars file, with the context +func (obj *Config) ListAllConfigByInfo(configInfo *GetConfigListInfo, vf *[]string, opts ...map[string]string) (int32, error) { + return obj.ListAllConfigByInfoWithContext(context.Background(), configInfo, vf, opts...) +} + // ListAllConfigByInfoWithContext is the proxy function for the method defined in the tars file, with the context func (obj *Config) ListAllConfigByInfoWithContext(tarsCtx context.Context, configInfo *GetConfigListInfo, vf *[]string, opts ...map[string]string) (ret int32, err error) { var ( @@ -1937,9 +1111,9 @@ func (obj *Config) ListAllConfigByInfoWithContext(tarsCtx context.Context, confi } *vf = make([]string, length) - for i5, e5 := int32(0), length; i5 < e5; i5++ { + for i2, e2 := int32(0), length; i2 < e2; i2++ { - err = readBuf.ReadString(&(*vf)[i5], 0, false) + err = readBuf.ReadString(&(*vf)[i2], 0, false) if err != nil { return ret, err } @@ -2033,48 +1207,12 @@ func (obj *Config) ListAllConfigByInfoOneWayWithContext(tarsCtx context.Context, return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// SetServant sets servant for the service. -func (obj *Config) SetServant(servant m.Servant) { - obj.servant = servant -} - -// TarsSetTimeout sets the timeout for the servant which is in ms. -func (obj *Config) TarsSetTimeout(timeout int) { - obj.servant.TarsSetTimeout(timeout) -} - -// TarsSetProtocol sets the protocol for the servant. -func (obj *Config) TarsSetProtocol(p m.Protocol) { - obj.servant.TarsSetProtocol(p) -} - type ConfigServant interface { ListConfig(app string, server string, vf *[]string) (ret int32, err error) LoadConfig(app string, server string, filename string, config *string) (ret int32, err error) diff --git a/tars/protocol/res/configf/ConfigF.go b/tars/protocol/res/configf/ConfigF.go index 5b29a173..8797757b 100644 --- a/tars/protocol/res/configf/ConfigF.go +++ b/tars/protocol/res/configf/ConfigF.go @@ -1,5 +1,5 @@ // Package configf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from ConfigF.tars package configf diff --git a/tars/protocol/res/endpointf/EndpointF.go b/tars/protocol/res/endpointf/EndpointF.go index 21799dbf..6a6de8b4 100644 --- a/tars/protocol/res/endpointf/EndpointF.go +++ b/tars/protocol/res/endpointf/EndpointF.go @@ -1,5 +1,5 @@ // Package endpointf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from EndpointF.tars package endpointf diff --git a/tars/protocol/res/logf/Log.tars.go b/tars/protocol/res/logf/Log.tars.go index ee986eb2..afdf5740 100644 --- a/tars/protocol/res/logf/Log.tars.go +++ b/tars/protocol/res/logf/Log.tars.go @@ -1,5 +1,5 @@ // Package logf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from LogF.tars package logf @@ -14,6 +14,7 @@ import ( "github.com/TarsCloud/TarsGo/tars/protocol/res/requestf" "github.com/TarsCloud/TarsGo/tars/protocol/tup" "github.com/TarsCloud/TarsGo/tars/util/current" + "github.com/TarsCloud/TarsGo/tars/util/endpoint" "github.com/TarsCloud/TarsGo/tars/util/tools" "unsafe" ) @@ -31,94 +32,29 @@ type Log struct { servant m.Servant } -// Logger is the proxy function for the method defined in the tars file, with the context -func (obj *Log) Logger(app string, server string, file string, format string, buffer []string, opts ...map[string]string) (err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(app, 1) - if err != nil { - return err - } - - err = buf.WriteString(server, 2) - if err != nil { - return err - } - - err = buf.WriteString(file, 3) - if err != nil { - return err - } - - err = buf.WriteString(format, 4) - if err != nil { - return err - } - - err = buf.WriteHead(codec.LIST, 5) - if err != nil { - return err - } - - err = buf.WriteInt32(int32(len(buffer)), 0) - if err != nil { - return err - } - - for _, v := range buffer { - - err = buf.WriteString(v, 0) - if err != nil { - return err - } +// SetServant sets servant for the service. +func (obj *Log) SetServant(servant m.Servant) { + obj.servant = servant +} - } +// TarsSetTimeout sets the timeout for the servant which is in ms. +func (obj *Log) TarsSetTimeout(timeout int) { + obj.servant.TarsSetTimeout(timeout) +} - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() +// TarsSetProtocol sets the protocol for the servant. +func (obj *Log) TarsSetProtocol(p m.Protocol) { + obj.servant.TarsSetProtocol(p) +} - err = obj.servant.TarsInvoke(tarsCtx, 0, "logger", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return err - } +// Endpoints returns all active endpoint.Endpoint +func (obj *Log) Endpoints() []*endpoint.Endpoint { + return obj.servant.Endpoints() +} - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return nil +// Logger is the proxy function for the method defined in the tars file, with the context +func (obj *Log) Logger(app string, server string, file string, format string, buffer []string, opts ...map[string]string) error { + return obj.LoggerWithContext(context.Background(), app, server, file, format, buffer, opts...) } // LoggerWithContext is the proxy function for the method defined in the tars file, with the context @@ -272,27 +208,6 @@ func (obj *Log) LoggerOneWayWithContext(tarsCtx context.Context, app string, ser return err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty @@ -300,78 +215,8 @@ func (obj *Log) LoggerOneWayWithContext(tarsCtx context.Context, app string, ser } // LoggerbyInfo is the proxy function for the method defined in the tars file, with the context -func (obj *Log) LoggerbyInfo(info *LogInfo, buffer []string, opts ...map[string]string) (err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = info.WriteBlock(buf, 1) - if err != nil { - return err - } - - err = buf.WriteHead(codec.LIST, 2) - if err != nil { - return err - } - - err = buf.WriteInt32(int32(len(buffer)), 0) - if err != nil { - return err - } - - for _, v := range buffer { - - err = buf.WriteString(v, 0) - if err != nil { - return err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "loggerbyInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return nil +func (obj *Log) LoggerbyInfo(info *LogInfo, buffer []string, opts ...map[string]string) error { + return obj.LoggerbyInfoWithContext(context.Background(), info, buffer, opts...) } // LoggerbyInfoWithContext is the proxy function for the method defined in the tars file, with the context @@ -495,48 +340,12 @@ func (obj *Log) LoggerbyInfoOneWayWithContext(tarsCtx context.Context, info *Log return err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return nil } -// SetServant sets servant for the service. -func (obj *Log) SetServant(servant m.Servant) { - obj.servant = servant -} - -// TarsSetTimeout sets the timeout for the servant which is in ms. -func (obj *Log) TarsSetTimeout(timeout int) { - obj.servant.TarsSetTimeout(timeout) -} - -// TarsSetProtocol sets the protocol for the servant. -func (obj *Log) TarsSetProtocol(p m.Protocol) { - obj.servant.TarsSetProtocol(p) -} - type LogServant interface { Logger(app string, server string, file string, format string, buffer []string) (err error) LoggerbyInfo(info *LogInfo, buffer []string) (err error) diff --git a/tars/protocol/res/logf/LogF.go b/tars/protocol/res/logf/LogF.go index 1b17e45c..55bc2987 100644 --- a/tars/protocol/res/logf/LogF.go +++ b/tars/protocol/res/logf/LogF.go @@ -1,5 +1,5 @@ // Package logf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from LogF.tars package logf diff --git a/tars/protocol/res/nodef/NodeF.go b/tars/protocol/res/nodef/NodeF.go index 242e5524..5e1eddeb 100644 --- a/tars/protocol/res/nodef/NodeF.go +++ b/tars/protocol/res/nodef/NodeF.go @@ -1,5 +1,5 @@ // Package nodef comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from NodeF.tars package nodef diff --git a/tars/protocol/res/nodef/ServerF.tars.go b/tars/protocol/res/nodef/ServerF.tars.go index ccc2b7a1..fbbb14d6 100644 --- a/tars/protocol/res/nodef/ServerF.tars.go +++ b/tars/protocol/res/nodef/ServerF.tars.go @@ -1,5 +1,5 @@ // Package nodef comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from NodeF.tars package nodef @@ -14,6 +14,7 @@ import ( "github.com/TarsCloud/TarsGo/tars/protocol/res/requestf" "github.com/TarsCloud/TarsGo/tars/protocol/tup" "github.com/TarsCloud/TarsGo/tars/util/current" + "github.com/TarsCloud/TarsGo/tars/util/endpoint" "github.com/TarsCloud/TarsGo/tars/util/tools" "unsafe" ) @@ -31,66 +32,29 @@ type ServerF struct { servant m.Servant } -// KeepAlive is the proxy function for the method defined in the tars file, with the context -func (obj *ServerF) KeepAlive(serverInfo *ServerInfo, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = serverInfo.WriteBlock(buf, 1) - if err != nil { - return ret, err - } +// SetServant sets servant for the service. +func (obj *ServerF) SetServant(servant m.Servant) { + obj.servant = servant +} - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() +// TarsSetTimeout sets the timeout for the servant which is in ms. +func (obj *ServerF) TarsSetTimeout(timeout int) { + obj.servant.TarsSetTimeout(timeout) +} - err = obj.servant.TarsInvoke(tarsCtx, 0, "keepAlive", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } +// TarsSetProtocol sets the protocol for the servant. +func (obj *ServerF) TarsSetProtocol(p m.Protocol) { + obj.servant.TarsSetProtocol(p) +} - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } +// Endpoints returns all active endpoint.Endpoint +func (obj *ServerF) Endpoints() []*endpoint.Endpoint { + return obj.servant.Endpoints() +} - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil +// KeepAlive is the proxy function for the method defined in the tars file, with the context +func (obj *ServerF) KeepAlive(serverInfo *ServerInfo, opts ...map[string]string) (int32, error) { + return obj.KeepAliveWithContext(context.Background(), serverInfo, opts...) } // KeepAliveWithContext is the proxy function for the method defined in the tars file, with the context @@ -182,27 +146,6 @@ func (obj *ServerF) KeepAliveOneWayWithContext(tarsCtx context.Context, serverIn return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty @@ -210,75 +153,8 @@ func (obj *ServerF) KeepAliveOneWayWithContext(tarsCtx context.Context, serverIn } // ReportVersion is the proxy function for the method defined in the tars file, with the context -func (obj *ServerF) ReportVersion(app string, serverName string, version string, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(app, 1) - if err != nil { - return ret, err - } - - err = buf.WriteString(serverName, 2) - if err != nil { - return ret, err - } - - err = buf.WriteString(version, 3) - if err != nil { - return ret, err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "reportVersion", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil +func (obj *ServerF) ReportVersion(app string, serverName string, version string, opts ...map[string]string) (int32, error) { + return obj.ReportVersionWithContext(context.Background(), app, serverName, version, opts...) } // ReportVersionWithContext is the proxy function for the method defined in the tars file, with the context @@ -390,48 +266,12 @@ func (obj *ServerF) ReportVersionOneWayWithContext(tarsCtx context.Context, app return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// SetServant sets servant for the service. -func (obj *ServerF) SetServant(servant m.Servant) { - obj.servant = servant -} - -// TarsSetTimeout sets the timeout for the servant which is in ms. -func (obj *ServerF) TarsSetTimeout(timeout int) { - obj.servant.TarsSetTimeout(timeout) -} - -// TarsSetProtocol sets the protocol for the servant. -func (obj *ServerF) TarsSetProtocol(p m.Protocol) { - obj.servant.TarsSetProtocol(p) -} - type ServerFServant interface { KeepAlive(serverInfo *ServerInfo) (ret int32, err error) ReportVersion(app string, serverName string, version string) (ret int32, err error) diff --git a/tars/protocol/res/notifyf/Notify.tars.go b/tars/protocol/res/notifyf/Notify.tars.go index 757bbc78..2a3ef65b 100644 --- a/tars/protocol/res/notifyf/Notify.tars.go +++ b/tars/protocol/res/notifyf/Notify.tars.go @@ -1,5 +1,5 @@ // Package notifyf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from NotifyF.tars package notifyf @@ -14,6 +14,7 @@ import ( "github.com/TarsCloud/TarsGo/tars/protocol/res/requestf" "github.com/TarsCloud/TarsGo/tars/protocol/tup" "github.com/TarsCloud/TarsGo/tars/util/current" + "github.com/TarsCloud/TarsGo/tars/util/endpoint" "github.com/TarsCloud/TarsGo/tars/util/tools" "unsafe" ) @@ -31,70 +32,29 @@ type Notify struct { servant m.Servant } -// ReportServer is the proxy function for the method defined in the tars file, with the context -func (obj *Notify) ReportServer(sServerName string, sThreadId string, sMessage string, opts ...map[string]string) (err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(sServerName, 1) - if err != nil { - return err - } - - err = buf.WriteString(sThreadId, 2) - if err != nil { - return err - } +// SetServant sets servant for the service. +func (obj *Notify) SetServant(servant m.Servant) { + obj.servant = servant +} - err = buf.WriteString(sMessage, 3) - if err != nil { - return err - } +// TarsSetTimeout sets the timeout for the servant which is in ms. +func (obj *Notify) TarsSetTimeout(timeout int) { + obj.servant.TarsSetTimeout(timeout) +} - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() +// TarsSetProtocol sets the protocol for the servant. +func (obj *Notify) TarsSetProtocol(p m.Protocol) { + obj.servant.TarsSetProtocol(p) +} - err = obj.servant.TarsInvoke(tarsCtx, 0, "reportServer", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return err - } +// Endpoints returns all active endpoint.Endpoint +func (obj *Notify) Endpoints() []*endpoint.Endpoint { + return obj.servant.Endpoints() +} - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return nil +// ReportServer is the proxy function for the method defined in the tars file, with the context +func (obj *Notify) ReportServer(sServerName string, sThreadId string, sMessage string, opts ...map[string]string) error { + return obj.ReportServerWithContext(context.Background(), sServerName, sThreadId, sMessage, opts...) } // ReportServerWithContext is the proxy function for the method defined in the tars file, with the context @@ -200,27 +160,6 @@ func (obj *Notify) ReportServerOneWayWithContext(tarsCtx context.Context, sServe return err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty @@ -228,69 +167,8 @@ func (obj *Notify) ReportServerOneWayWithContext(tarsCtx context.Context, sServe } // NotifyServer is the proxy function for the method defined in the tars file, with the context -func (obj *Notify) NotifyServer(sServerName string, level NOTIFYLEVEL, sMessage string, opts ...map[string]string) (err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(sServerName, 1) - if err != nil { - return err - } - - err = buf.WriteInt32(int32(level), 2) - if err != nil { - return err - } - - err = buf.WriteString(sMessage, 3) - if err != nil { - return err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "notifyServer", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return nil +func (obj *Notify) NotifyServer(sServerName string, level NOTIFYLEVEL, sMessage string, opts ...map[string]string) error { + return obj.NotifyServerWithContext(context.Background(), sServerName, level, sMessage, opts...) } // NotifyServerWithContext is the proxy function for the method defined in the tars file, with the context @@ -396,27 +274,6 @@ func (obj *Notify) NotifyServerOneWayWithContext(tarsCtx context.Context, sServe return err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty @@ -424,75 +281,8 @@ func (obj *Notify) NotifyServerOneWayWithContext(tarsCtx context.Context, sServe } // GetNotifyInfo is the proxy function for the method defined in the tars file, with the context -func (obj *Notify) GetNotifyInfo(stKey *NotifyKey, stInfo *NotifyInfo, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = stKey.WriteBlock(buf, 1) - if err != nil { - return ret, err - } - - err = (*stInfo).WriteBlock(buf, 2) - if err != nil { - return ret, err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "getNotifyInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - err = (*stInfo).ReadBlock(readBuf, 2, true) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil +func (obj *Notify) GetNotifyInfo(stKey *NotifyKey, stInfo *NotifyInfo, opts ...map[string]string) (int32, error) { + return obj.GetNotifyInfoWithContext(context.Background(), stKey, stInfo, opts...) } // GetNotifyInfoWithContext is the proxy function for the method defined in the tars file, with the context @@ -599,27 +389,6 @@ func (obj *Notify) GetNotifyInfoOneWayWithContext(tarsCtx context.Context, stKey return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty @@ -627,59 +396,8 @@ func (obj *Notify) GetNotifyInfoOneWayWithContext(tarsCtx context.Context, stKey } // ReportNotifyInfo is the proxy function for the method defined in the tars file, with the context -func (obj *Notify) ReportNotifyInfo(info *ReportInfo, opts ...map[string]string) (err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = info.WriteBlock(buf, 1) - if err != nil { - return err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "reportNotifyInfo", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return nil +func (obj *Notify) ReportNotifyInfo(info *ReportInfo, opts ...map[string]string) error { + return obj.ReportNotifyInfoWithContext(context.Background(), info, opts...) } // ReportNotifyInfoWithContext is the proxy function for the method defined in the tars file, with the context @@ -765,48 +483,12 @@ func (obj *Notify) ReportNotifyInfoOneWayWithContext(tarsCtx context.Context, in return err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return nil } -// SetServant sets servant for the service. -func (obj *Notify) SetServant(servant m.Servant) { - obj.servant = servant -} - -// TarsSetTimeout sets the timeout for the servant which is in ms. -func (obj *Notify) TarsSetTimeout(timeout int) { - obj.servant.TarsSetTimeout(timeout) -} - -// TarsSetProtocol sets the protocol for the servant. -func (obj *Notify) TarsSetProtocol(p m.Protocol) { - obj.servant.TarsSetProtocol(p) -} - type NotifyServant interface { ReportServer(sServerName string, sThreadId string, sMessage string) (err error) NotifyServer(sServerName string, level NOTIFYLEVEL, sMessage string) (err error) diff --git a/tars/protocol/res/notifyf/NotifyF.go b/tars/protocol/res/notifyf/NotifyF.go index 946ff79e..5e64df04 100644 --- a/tars/protocol/res/notifyf/NotifyF.go +++ b/tars/protocol/res/notifyf/NotifyF.go @@ -1,5 +1,5 @@ // Package notifyf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from NotifyF.tars package notifyf diff --git a/tars/protocol/res/propertyf/PropertyF.go b/tars/protocol/res/propertyf/PropertyF.go index f9d5c2b6..4c43ff67 100644 --- a/tars/protocol/res/propertyf/PropertyF.go +++ b/tars/protocol/res/propertyf/PropertyF.go @@ -1,5 +1,5 @@ // Package propertyf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from PropertyF.tars package propertyf diff --git a/tars/protocol/res/propertyf/PropertyF.tars.go b/tars/protocol/res/propertyf/PropertyF.tars.go index 390cc942..0c758305 100644 --- a/tars/protocol/res/propertyf/PropertyF.tars.go +++ b/tars/protocol/res/propertyf/PropertyF.tars.go @@ -1,5 +1,5 @@ // Package propertyf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from PropertyF.tars package propertyf @@ -14,6 +14,7 @@ import ( "github.com/TarsCloud/TarsGo/tars/protocol/res/requestf" "github.com/TarsCloud/TarsGo/tars/protocol/tup" "github.com/TarsCloud/TarsGo/tars/util/current" + "github.com/TarsCloud/TarsGo/tars/util/endpoint" "github.com/TarsCloud/TarsGo/tars/util/tools" "unsafe" ) @@ -31,85 +32,29 @@ type PropertyF struct { servant m.Servant } -// ReportPropMsg is the proxy function for the method defined in the tars file, with the context -func (obj *PropertyF) ReportPropMsg(statmsg map[StatPropMsgHead]StatPropMsgBody, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteHead(codec.MAP, 1) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(statmsg)), 0) - if err != nil { - return ret, err - } - - for k1, v1 := range statmsg { - - err = k1.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - err = v1.WriteBlock(buf, 1) - if err != nil { - return ret, err - } - - } +// SetServant sets servant for the service. +func (obj *PropertyF) SetServant(servant m.Servant) { + obj.servant = servant +} - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() +// TarsSetTimeout sets the timeout for the servant which is in ms. +func (obj *PropertyF) TarsSetTimeout(timeout int) { + obj.servant.TarsSetTimeout(timeout) +} - err = obj.servant.TarsInvoke(tarsCtx, 0, "reportPropMsg", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } +// TarsSetProtocol sets the protocol for the servant. +func (obj *PropertyF) TarsSetProtocol(p m.Protocol) { + obj.servant.TarsSetProtocol(p) +} - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } +// Endpoints returns all active endpoint.Endpoint +func (obj *PropertyF) Endpoints() []*endpoint.Endpoint { + return obj.servant.Endpoints() +} - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil +// ReportPropMsg is the proxy function for the method defined in the tars file, with the context +func (obj *PropertyF) ReportPropMsg(statmsg map[StatPropMsgHead]StatPropMsgBody, opts ...map[string]string) (int32, error) { + return obj.ReportPropMsgWithContext(context.Background(), statmsg, opts...) } // ReportPropMsgWithContext is the proxy function for the method defined in the tars file, with the context @@ -130,14 +75,14 @@ func (obj *PropertyF) ReportPropMsgWithContext(tarsCtx context.Context, statmsg return ret, err } - for k2, v2 := range statmsg { + for k1, v1 := range statmsg { - err = k2.WriteBlock(buf, 0) + err = k1.WriteBlock(buf, 0) if err != nil { return ret, err } - err = v2.WriteBlock(buf, 1) + err = v1.WriteBlock(buf, 1) if err != nil { return ret, err } @@ -210,14 +155,14 @@ func (obj *PropertyF) ReportPropMsgOneWayWithContext(tarsCtx context.Context, st return ret, err } - for k3, v3 := range statmsg { + for k2, v2 := range statmsg { - err = k3.WriteBlock(buf, 0) + err = k2.WriteBlock(buf, 0) if err != nil { return ret, err } - err = v3.WriteBlock(buf, 1) + err = v2.WriteBlock(buf, 1) if err != nil { return ret, err } @@ -239,48 +184,12 @@ func (obj *PropertyF) ReportPropMsgOneWayWithContext(tarsCtx context.Context, st return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// SetServant sets servant for the service. -func (obj *PropertyF) SetServant(servant m.Servant) { - obj.servant = servant -} - -// TarsSetTimeout sets the timeout for the servant which is in ms. -func (obj *PropertyF) TarsSetTimeout(timeout int) { - obj.servant.TarsSetTimeout(timeout) -} - -// TarsSetProtocol sets the protocol for the servant. -func (obj *PropertyF) TarsSetProtocol(p m.Protocol) { - obj.servant.TarsSetProtocol(p) -} - type PropertyFServant interface { ReportPropMsg(statmsg map[StatPropMsgHead]StatPropMsgBody) (ret int32, err error) } @@ -315,21 +224,21 @@ func (obj *PropertyF) Dispatch(tarsCtx context.Context, val interface{}, tarsReq } statmsg = make(map[StatPropMsgHead]StatPropMsgBody) - for i4, e4 := int32(0), length; i4 < e4; i4++ { - var k4 StatPropMsgHead - var v4 StatPropMsgBody + for i3, e3 := int32(0), length; i3 < e3; i3++ { + var k3 StatPropMsgHead + var v3 StatPropMsgBody - err = k4.ReadBlock(readBuf, 0, false) + err = k3.ReadBlock(readBuf, 0, false) if err != nil { return err } - err = v4.ReadBlock(readBuf, 1, false) + err = v3.ReadBlock(readBuf, 1, false) if err != nil { return err } - statmsg[k4] = v4 + statmsg[k3] = v3 } } else if tarsReq.IVersion == basef.TUPVERSION { reqTup := tup.NewUniAttribute() @@ -350,21 +259,21 @@ func (obj *PropertyF) Dispatch(tarsCtx context.Context, val interface{}, tarsReq } statmsg = make(map[StatPropMsgHead]StatPropMsgBody) - for i5, e5 := int32(0), length; i5 < e5; i5++ { - var k5 StatPropMsgHead - var v5 StatPropMsgBody + for i4, e4 := int32(0), length; i4 < e4; i4++ { + var k4 StatPropMsgHead + var v4 StatPropMsgBody - err = k5.ReadBlock(readBuf, 0, false) + err = k4.ReadBlock(readBuf, 0, false) if err != nil { return err } - err = v5.ReadBlock(readBuf, 1, false) + err = v4.ReadBlock(readBuf, 1, false) if err != nil { return err } - statmsg[k5] = v5 + statmsg[k4] = v4 } } else if tarsReq.IVersion == basef.JSONVERSION { var jsonData map[string]interface{} diff --git a/tars/protocol/res/queryf/QueryF.tars.go b/tars/protocol/res/queryf/QueryF.tars.go index ea82d7ea..37bb9721 100644 --- a/tars/protocol/res/queryf/QueryF.tars.go +++ b/tars/protocol/res/queryf/QueryF.tars.go @@ -1,5 +1,5 @@ // Package queryf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from QueryF.tars package queryf @@ -7,14 +7,15 @@ import ( "bytes" "context" "encoding/json" - "github.com/TarsCloud/TarsGo/tars/protocol/res/endpointf" "fmt" m "github.com/TarsCloud/TarsGo/tars/model" "github.com/TarsCloud/TarsGo/tars/protocol/codec" "github.com/TarsCloud/TarsGo/tars/protocol/res/basef" + "github.com/TarsCloud/TarsGo/tars/protocol/res/endpointf" "github.com/TarsCloud/TarsGo/tars/protocol/res/requestf" "github.com/TarsCloud/TarsGo/tars/protocol/tup" "github.com/TarsCloud/TarsGo/tars/util/current" + "github.com/TarsCloud/TarsGo/tars/util/endpoint" "github.com/TarsCloud/TarsGo/tars/util/tools" "unsafe" ) @@ -32,95 +33,29 @@ type QueryF struct { servant m.Servant } -// FindObjectById is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectById(id string, opts ...map[string]string) (ret []endpointf.EndpointF, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(id, 1) - if err != nil { - return ret, err - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectById", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - _, ty, err = readBuf.SkipToNoCheck(0, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - ret = make([]endpointf.EndpointF, length) - for i0, e0 := int32(0), length; i0 < e0; i0++ { - - err = ret[i0].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } +// SetServant sets servant for the service. +func (obj *QueryF) SetServant(servant m.Servant) { + obj.servant = servant +} - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } +// TarsSetTimeout sets the timeout for the servant which is in ms. +func (obj *QueryF) TarsSetTimeout(timeout int) { + obj.servant.TarsSetTimeout(timeout) +} - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } +// TarsSetProtocol sets the protocol for the servant. +func (obj *QueryF) TarsSetProtocol(p m.Protocol) { + obj.servant.TarsSetProtocol(p) +} - } +// Endpoints returns all active endpoint.Endpoint +func (obj *QueryF) Endpoints() []*endpoint.Endpoint { + return obj.servant.Endpoints() +} - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil +// FindObjectById is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectById(id string, opts ...map[string]string) ([]endpointf.EndpointF, error) { + return obj.FindObjectByIdWithContext(context.Background(), id, opts...) } // FindObjectByIdWithContext is the proxy function for the method defined in the tars file, with the context @@ -164,9 +99,9 @@ func (obj *QueryF) FindObjectByIdWithContext(tarsCtx context.Context, id string, } ret = make([]endpointf.EndpointF, length) - for i1, e1 := int32(0), length; i1 < e1; i1++ { + for i0, e0 := int32(0), length; i0 < e0; i0++ { - err = ret[i1].ReadBlock(readBuf, 0, false) + err = ret[i0].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -241,27 +176,6 @@ func (obj *QueryF) FindObjectByIdOneWayWithContext(tarsCtx context.Context, id s return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty @@ -269,7 +183,12 @@ func (obj *QueryF) FindObjectByIdOneWayWithContext(tarsCtx context.Context, id s } // FindObjectById4Any is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectById4Any(id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { +func (obj *QueryF) FindObjectById4Any(id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (int32, error) { + return obj.FindObjectById4AnyWithContext(context.Background(), id, activeEp, inactiveEp, opts...) +} + +// FindObjectById4AnyWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectById4AnyWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -327,9 +246,8 @@ func (obj *QueryF) FindObjectById4Any(id string, activeEp *[]endpointf.EndpointF contextMap = opts[0] statusMap = opts[1] } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() + tarsResp := new(requestf.ResponsePacket) err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectById4Any", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err @@ -353,9 +271,9 @@ func (obj *QueryF) FindObjectById4Any(id string, activeEp *[]endpointf.EndpointF } *activeEp = make([]endpointf.EndpointF, length) - for i2, e2 := int32(0), length; i2 < e2; i2++ { + for i1, e1 := int32(0), length; i1 < e1; i1++ { - err = (*activeEp)[i2].ReadBlock(readBuf, 0, false) + err = (*activeEp)[i1].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -387,9 +305,9 @@ func (obj *QueryF) FindObjectById4Any(id string, activeEp *[]endpointf.EndpointF } *inactiveEp = make([]endpointf.EndpointF, length) - for i3, e3 := int32(0), length; i3 < e3; i3++ { + for i2, e2 := int32(0), length; i2 < e2; i2++ { - err = (*inactiveEp)[i3].ReadBlock(readBuf, 0, false) + err = (*inactiveEp)[i2].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -436,8 +354,8 @@ func (obj *QueryF) FindObjectById4Any(id string, activeEp *[]endpointf.EndpointF return ret, nil } -// FindObjectById4AnyWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectById4AnyWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { +// FindObjectById4AnyOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectById4AnyOneWayWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -497,114 +415,24 @@ func (obj *QueryF) FindObjectById4AnyWithContext(tarsCtx context.Context, id str } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectById4Any", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - _, ty, err = readBuf.SkipToNoCheck(2, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *activeEp = make([]endpointf.EndpointF, length) - for i4, e4 := int32(0), length; i4 < e4; i4++ { - - err = (*activeEp)[i4].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - _, ty, err = readBuf.SkipToNoCheck(3, true) + err = obj.servant.TarsInvoke(tarsCtx, 1, "findObjectById4Any", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *inactiveEp = make([]endpointf.EndpointF, length) - for i5, e5 := int32(0), length; i5 < e5; i5++ { - - err = (*inactiveEp)[i5].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// FindObjectById4AnyOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectById4AnyOneWayWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { +// FindObjectById4All is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectById4All(id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (int32, error) { + return obj.FindObjectById4AllWithContext(context.Background(), id, activeEp, inactiveEp, opts...) +} + +// FindObjectById4AllWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectById4AllWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -664,268 +492,7 @@ func (obj *QueryF) FindObjectById4AnyOneWayWithContext(tarsCtx context.Context, } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "findObjectById4Any", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// FindObjectById4All is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectById4All(id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(id, 1) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 2) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*activeEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *activeEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - err = buf.WriteHead(codec.LIST, 3) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*inactiveEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *inactiveEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectById4All", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - _, ty, err = readBuf.SkipToNoCheck(2, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *activeEp = make([]endpointf.EndpointF, length) - for i6, e6 := int32(0), length; i6 < e6; i6++ { - - err = (*activeEp)[i6].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - _, ty, err = readBuf.SkipToNoCheck(3, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *inactiveEp = make([]endpointf.EndpointF, length) - for i7, e7 := int32(0), length; i7 < e7; i7++ { - - err = (*inactiveEp)[i7].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// FindObjectById4AllWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectById4AllWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(id, 1) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 2) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*activeEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *activeEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - err = buf.WriteHead(codec.LIST, 3) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*inactiveEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *inactiveEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - - tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectById4All", buf.ToBytes(), statusMap, contextMap, tarsResp) + err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectById4All", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } @@ -948,9 +515,9 @@ func (obj *QueryF) FindObjectById4AllWithContext(tarsCtx context.Context, id str } *activeEp = make([]endpointf.EndpointF, length) - for i8, e8 := int32(0), length; i8 < e8; i8++ { + for i3, e3 := int32(0), length; i3 < e3; i3++ { - err = (*activeEp)[i8].ReadBlock(readBuf, 0, false) + err = (*activeEp)[i3].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -970,701 +537,7 @@ func (obj *QueryF) FindObjectById4AllWithContext(tarsCtx context.Context, id str } - _, ty, err = readBuf.SkipToNoCheck(3, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *inactiveEp = make([]endpointf.EndpointF, length) - for i9, e9 := int32(0), length; i9 < e9; i9++ { - - err = (*inactiveEp)[i9].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// FindObjectById4AllOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectById4AllOneWayWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(id, 1) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 2) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*activeEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *activeEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - err = buf.WriteHead(codec.LIST, 3) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*inactiveEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *inactiveEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - - tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "findObjectById4All", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// FindObjectByIdInSameGroup is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectByIdInSameGroup(id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(id, 1) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 2) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*activeEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *activeEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - err = buf.WriteHead(codec.LIST, 3) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*inactiveEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *inactiveEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectByIdInSameGroup", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - _, ty, err = readBuf.SkipToNoCheck(2, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *activeEp = make([]endpointf.EndpointF, length) - for i10, e10 := int32(0), length; i10 < e10; i10++ { - - err = (*activeEp)[i10].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - _, ty, err = readBuf.SkipToNoCheck(3, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *inactiveEp = make([]endpointf.EndpointF, length) - for i11, e11 := int32(0), length; i11 < e11; i11++ { - - err = (*inactiveEp)[i11].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// FindObjectByIdInSameGroupWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectByIdInSameGroupWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(id, 1) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 2) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*activeEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *activeEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - err = buf.WriteHead(codec.LIST, 3) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*inactiveEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *inactiveEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - - tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectByIdInSameGroup", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - _, ty, err = readBuf.SkipToNoCheck(2, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *activeEp = make([]endpointf.EndpointF, length) - for i12, e12 := int32(0), length; i12 < e12; i12++ { - - err = (*activeEp)[i12].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - _, ty, err = readBuf.SkipToNoCheck(3, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *inactiveEp = make([]endpointf.EndpointF, length) - for i13, e13 := int32(0), length; i13 < e13; i13++ { - - err = (*inactiveEp)[i13].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// FindObjectByIdInSameGroupOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectByIdInSameGroupOneWayWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(id, 1) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 2) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*activeEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *activeEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - err = buf.WriteHead(codec.LIST, 3) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*inactiveEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *inactiveEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - - tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "findObjectByIdInSameGroup", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil -} - -// FindObjectByIdInSameStation is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectByIdInSameStation(id string, sStation string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteString(id, 1) - if err != nil { - return ret, err - } - - err = buf.WriteString(sStation, 2) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 3) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*activeEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *activeEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - err = buf.WriteHead(codec.LIST, 4) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(*inactiveEp)), 0) - if err != nil { - return ret, err - } - - for _, v := range *inactiveEp { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectByIdInSameStation", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - _, ty, err = readBuf.SkipToNoCheck(3, true) - if err != nil { - return ret, err - } - - if ty == codec.LIST { - err = readBuf.ReadInt32(&length, 0, true) - if err != nil { - return ret, err - } - - *activeEp = make([]endpointf.EndpointF, length) - for i14, e14 := int32(0), length; i14 < e14; i14++ { - - err = (*activeEp)[i14].ReadBlock(readBuf, 0, false) - if err != nil { - return ret, err - } - - } - } else if ty == codec.SimpleList { - err = fmt.Errorf("not support SimpleList type") - if err != nil { - return ret, err - } - - } else { - err = fmt.Errorf("require vector, but not") - if err != nil { - return ret, err - } - - } - - _, ty, err = readBuf.SkipToNoCheck(4, true) + _, ty, err = readBuf.SkipToNoCheck(3, true) if err != nil { return ret, err } @@ -1676,9 +549,9 @@ func (obj *QueryF) FindObjectByIdInSameStation(id string, sStation string, activ } *inactiveEp = make([]endpointf.EndpointF, length) - for i15, e15 := int32(0), length; i15 < e15; i15++ { + for i4, e4 := int32(0), length; i4 < e4; i4++ { - err = (*inactiveEp)[i15].ReadBlock(readBuf, 0, false) + err = (*inactiveEp)[i4].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -1725,8 +598,8 @@ func (obj *QueryF) FindObjectByIdInSameStation(id string, sStation string, activ return ret, nil } -// FindObjectByIdInSameStationWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectByIdInSameStationWithContext(tarsCtx context.Context, id string, sStation string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { +// FindObjectById4AllOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectById4AllOneWayWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -1738,16 +611,88 @@ func (obj *QueryF) FindObjectByIdInSameStationWithContext(tarsCtx context.Contex return ret, err } - err = buf.WriteString(sStation, 2) + err = buf.WriteHead(codec.LIST, 2) if err != nil { return ret, err } + err = buf.WriteInt32(int32(len(*activeEp)), 0) + if err != nil { + return ret, err + } + + for _, v := range *activeEp { + + err = v.WriteBlock(buf, 0) + if err != nil { + return ret, err + } + + } + err = buf.WriteHead(codec.LIST, 3) if err != nil { return ret, err } + err = buf.WriteInt32(int32(len(*inactiveEp)), 0) + if err != nil { + return ret, err + } + + for _, v := range *inactiveEp { + + err = v.WriteBlock(buf, 0) + if err != nil { + return ret, err + } + + } + + var statusMap map[string]string + var contextMap map[string]string + if len(opts) == 1 { + contextMap = opts[0] + } else if len(opts) == 2 { + contextMap = opts[0] + statusMap = opts[1] + } + + tarsResp := new(requestf.ResponsePacket) + err = obj.servant.TarsInvoke(tarsCtx, 1, "findObjectById4All", buf.ToBytes(), statusMap, contextMap, tarsResp) + if err != nil { + return ret, err + } + + _ = length + _ = have + _ = ty + return ret, nil +} + +// FindObjectByIdInSameGroup is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectByIdInSameGroup(id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (int32, error) { + return obj.FindObjectByIdInSameGroupWithContext(context.Background(), id, activeEp, inactiveEp, opts...) +} + +// FindObjectByIdInSameGroupWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectByIdInSameGroupWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { + var ( + length int32 + have bool + ty byte + ) + buf := codec.NewBuffer() + err = buf.WriteString(id, 1) + if err != nil { + return ret, err + } + + err = buf.WriteHead(codec.LIST, 2) + if err != nil { + return ret, err + } + err = buf.WriteInt32(int32(len(*activeEp)), 0) if err != nil { return ret, err @@ -1762,7 +707,7 @@ func (obj *QueryF) FindObjectByIdInSameStationWithContext(tarsCtx context.Contex } - err = buf.WriteHead(codec.LIST, 4) + err = buf.WriteHead(codec.LIST, 3) if err != nil { return ret, err } @@ -1791,7 +736,7 @@ func (obj *QueryF) FindObjectByIdInSameStationWithContext(tarsCtx context.Contex } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectByIdInSameStation", buf.ToBytes(), statusMap, contextMap, tarsResp) + err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectByIdInSameGroup", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } @@ -1802,7 +747,7 @@ func (obj *QueryF) FindObjectByIdInSameStationWithContext(tarsCtx context.Contex return ret, err } - _, ty, err = readBuf.SkipToNoCheck(3, true) + _, ty, err = readBuf.SkipToNoCheck(2, true) if err != nil { return ret, err } @@ -1814,9 +759,9 @@ func (obj *QueryF) FindObjectByIdInSameStationWithContext(tarsCtx context.Contex } *activeEp = make([]endpointf.EndpointF, length) - for i16, e16 := int32(0), length; i16 < e16; i16++ { + for i5, e5 := int32(0), length; i5 < e5; i5++ { - err = (*activeEp)[i16].ReadBlock(readBuf, 0, false) + err = (*activeEp)[i5].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -1836,7 +781,7 @@ func (obj *QueryF) FindObjectByIdInSameStationWithContext(tarsCtx context.Contex } - _, ty, err = readBuf.SkipToNoCheck(4, true) + _, ty, err = readBuf.SkipToNoCheck(3, true) if err != nil { return ret, err } @@ -1848,9 +793,9 @@ func (obj *QueryF) FindObjectByIdInSameStationWithContext(tarsCtx context.Contex } *inactiveEp = make([]endpointf.EndpointF, length) - for i17, e17 := int32(0), length; i17 < e17; i17++ { + for i6, e6 := int32(0), length; i6 < e6; i6++ { - err = (*inactiveEp)[i17].ReadBlock(readBuf, 0, false) + err = (*inactiveEp)[i6].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -1897,8 +842,8 @@ func (obj *QueryF) FindObjectByIdInSameStationWithContext(tarsCtx context.Contex return ret, nil } -// FindObjectByIdInSameStationOneWayWithContext is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectByIdInSameStationOneWayWithContext(tarsCtx context.Context, id string, sStation string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { +// FindObjectByIdInSameGroupOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectByIdInSameGroupOneWayWithContext(tarsCtx context.Context, id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -1910,12 +855,7 @@ func (obj *QueryF) FindObjectByIdInSameStationOneWayWithContext(tarsCtx context. return ret, err } - err = buf.WriteString(sStation, 2) - if err != nil { - return ret, err - } - - err = buf.WriteHead(codec.LIST, 3) + err = buf.WriteHead(codec.LIST, 2) if err != nil { return ret, err } @@ -1934,7 +874,7 @@ func (obj *QueryF) FindObjectByIdInSameStationOneWayWithContext(tarsCtx context. } - err = buf.WriteHead(codec.LIST, 4) + err = buf.WriteHead(codec.LIST, 3) if err != nil { return ret, err } @@ -1963,40 +903,24 @@ func (obj *QueryF) FindObjectByIdInSameStationOneWayWithContext(tarsCtx context. } tarsResp := new(requestf.ResponsePacket) - err = obj.servant.TarsInvoke(tarsCtx, 1, "findObjectByIdInSameStation", buf.ToBytes(), statusMap, contextMap, tarsResp) + err = obj.servant.TarsInvoke(tarsCtx, 1, "findObjectByIdInSameGroup", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// FindObjectByIdInSameSet is the proxy function for the method defined in the tars file, with the context -func (obj *QueryF) FindObjectByIdInSameSet(id string, setId string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { +// FindObjectByIdInSameStation is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectByIdInSameStation(id string, sStation string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (int32, error) { + return obj.FindObjectByIdInSameStationWithContext(context.Background(), id, sStation, activeEp, inactiveEp, opts...) +} + +// FindObjectByIdInSameStationWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectByIdInSameStationWithContext(tarsCtx context.Context, id string, sStation string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { var ( length int32 have bool @@ -2008,7 +932,7 @@ func (obj *QueryF) FindObjectByIdInSameSet(id string, setId string, activeEp *[] return ret, err } - err = buf.WriteString(setId, 2) + err = buf.WriteString(sStation, 2) if err != nil { return ret, err } @@ -2059,10 +983,9 @@ func (obj *QueryF) FindObjectByIdInSameSet(id string, setId string, activeEp *[] contextMap = opts[0] statusMap = opts[1] } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectByIdInSameSet", buf.ToBytes(), statusMap, contextMap, tarsResp) + tarsResp := new(requestf.ResponsePacket) + err = obj.servant.TarsInvoke(tarsCtx, 0, "findObjectByIdInSameStation", buf.ToBytes(), statusMap, contextMap, tarsResp) if err != nil { return ret, err } @@ -2085,9 +1008,9 @@ func (obj *QueryF) FindObjectByIdInSameSet(id string, setId string, activeEp *[] } *activeEp = make([]endpointf.EndpointF, length) - for i18, e18 := int32(0), length; i18 < e18; i18++ { + for i7, e7 := int32(0), length; i7 < e7; i7++ { - err = (*activeEp)[i18].ReadBlock(readBuf, 0, false) + err = (*activeEp)[i7].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -2119,9 +1042,9 @@ func (obj *QueryF) FindObjectByIdInSameSet(id string, setId string, activeEp *[] } *inactiveEp = make([]endpointf.EndpointF, length) - for i19, e19 := int32(0), length; i19 < e19; i19++ { + for i8, e8 := int32(0), length; i8 < e8; i8++ { - err = (*inactiveEp)[i19].ReadBlock(readBuf, 0, false) + err = (*inactiveEp)[i8].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -2168,6 +1091,88 @@ func (obj *QueryF) FindObjectByIdInSameSet(id string, setId string, activeEp *[] return ret, nil } +// FindObjectByIdInSameStationOneWayWithContext is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectByIdInSameStationOneWayWithContext(tarsCtx context.Context, id string, sStation string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { + var ( + length int32 + have bool + ty byte + ) + buf := codec.NewBuffer() + err = buf.WriteString(id, 1) + if err != nil { + return ret, err + } + + err = buf.WriteString(sStation, 2) + if err != nil { + return ret, err + } + + err = buf.WriteHead(codec.LIST, 3) + if err != nil { + return ret, err + } + + err = buf.WriteInt32(int32(len(*activeEp)), 0) + if err != nil { + return ret, err + } + + for _, v := range *activeEp { + + err = v.WriteBlock(buf, 0) + if err != nil { + return ret, err + } + + } + + err = buf.WriteHead(codec.LIST, 4) + if err != nil { + return ret, err + } + + err = buf.WriteInt32(int32(len(*inactiveEp)), 0) + if err != nil { + return ret, err + } + + for _, v := range *inactiveEp { + + err = v.WriteBlock(buf, 0) + if err != nil { + return ret, err + } + + } + + var statusMap map[string]string + var contextMap map[string]string + if len(opts) == 1 { + contextMap = opts[0] + } else if len(opts) == 2 { + contextMap = opts[0] + statusMap = opts[1] + } + + tarsResp := new(requestf.ResponsePacket) + err = obj.servant.TarsInvoke(tarsCtx, 1, "findObjectByIdInSameStation", buf.ToBytes(), statusMap, contextMap, tarsResp) + if err != nil { + return ret, err + } + + _ = length + _ = have + _ = ty + return ret, nil +} + +// FindObjectByIdInSameSet is the proxy function for the method defined in the tars file, with the context +func (obj *QueryF) FindObjectByIdInSameSet(id string, setId string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (int32, error) { + return obj.FindObjectByIdInSameSetWithContext(context.Background(), id, setId, activeEp, inactiveEp, opts...) +} + // FindObjectByIdInSameSetWithContext is the proxy function for the method defined in the tars file, with the context func (obj *QueryF) FindObjectByIdInSameSetWithContext(tarsCtx context.Context, id string, setId string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF, opts ...map[string]string) (ret int32, err error) { var ( @@ -2257,9 +1262,9 @@ func (obj *QueryF) FindObjectByIdInSameSetWithContext(tarsCtx context.Context, i } *activeEp = make([]endpointf.EndpointF, length) - for i20, e20 := int32(0), length; i20 < e20; i20++ { + for i9, e9 := int32(0), length; i9 < e9; i9++ { - err = (*activeEp)[i20].ReadBlock(readBuf, 0, false) + err = (*activeEp)[i9].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -2291,9 +1296,9 @@ func (obj *QueryF) FindObjectByIdInSameSetWithContext(tarsCtx context.Context, i } *inactiveEp = make([]endpointf.EndpointF, length) - for i21, e21 := int32(0), length; i21 < e21; i21++ { + for i10, e10 := int32(0), length; i10 < e10; i10++ { - err = (*inactiveEp)[i21].ReadBlock(readBuf, 0, false) + err = (*inactiveEp)[i10].ReadBlock(readBuf, 0, false) if err != nil { return ret, err } @@ -2411,48 +1416,12 @@ func (obj *QueryF) FindObjectByIdInSameSetOneWayWithContext(tarsCtx context.Cont return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// SetServant sets servant for the service. -func (obj *QueryF) SetServant(servant m.Servant) { - obj.servant = servant -} - -// TarsSetTimeout sets the timeout for the servant which is in ms. -func (obj *QueryF) TarsSetTimeout(timeout int) { - obj.servant.TarsSetTimeout(timeout) -} - -// TarsSetProtocol sets the protocol for the servant. -func (obj *QueryF) TarsSetProtocol(p m.Protocol) { - obj.servant.TarsSetProtocol(p) -} - type QueryFServant interface { FindObjectById(id string) (ret []endpointf.EndpointF, err error) FindObjectById4Any(id string, activeEp *[]endpointf.EndpointF, inactiveEp *[]endpointf.EndpointF) (ret int32, err error) diff --git a/tars/protocol/res/requestf/RequestF.go b/tars/protocol/res/requestf/RequestF.go index 53295f71..ccce55d0 100644 --- a/tars/protocol/res/requestf/RequestF.go +++ b/tars/protocol/res/requestf/RequestF.go @@ -1,5 +1,5 @@ // Package requestf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from RequestF.tars package requestf diff --git a/tars/protocol/res/statf/StatF.go b/tars/protocol/res/statf/StatF.go index 1abd03ef..00b446d4 100644 --- a/tars/protocol/res/statf/StatF.go +++ b/tars/protocol/res/statf/StatF.go @@ -1,5 +1,5 @@ // Package statf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from StatF.tars package statf diff --git a/tars/protocol/res/statf/StatF.tars.go b/tars/protocol/res/statf/StatF.tars.go index c84f0cfe..6e53c12d 100644 --- a/tars/protocol/res/statf/StatF.tars.go +++ b/tars/protocol/res/statf/StatF.tars.go @@ -1,5 +1,5 @@ // Package statf comment -// This file was generated by tars2go 1.1.10 +// This file was generated by tars2go 1.2.1 // Generated from StatF.tars package statf @@ -14,6 +14,7 @@ import ( "github.com/TarsCloud/TarsGo/tars/protocol/res/requestf" "github.com/TarsCloud/TarsGo/tars/protocol/tup" "github.com/TarsCloud/TarsGo/tars/util/current" + "github.com/TarsCloud/TarsGo/tars/util/endpoint" "github.com/TarsCloud/TarsGo/tars/util/tools" "unsafe" ) @@ -31,90 +32,29 @@ type StatF struct { servant m.Servant } -// ReportMicMsg is the proxy function for the method defined in the tars file, with the context -func (obj *StatF) ReportMicMsg(msg map[StatMicMsgHead]StatMicMsgBody, bFromClient bool, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteHead(codec.MAP, 1) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(msg)), 0) - if err != nil { - return ret, err - } - - for k0, v0 := range msg { - - err = k0.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - err = v0.WriteBlock(buf, 1) - if err != nil { - return ret, err - } - - } - - err = buf.WriteBool(bFromClient, 2) - if err != nil { - return ret, err - } +// SetServant sets servant for the service. +func (obj *StatF) SetServant(servant m.Servant) { + obj.servant = servant +} - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() +// TarsSetTimeout sets the timeout for the servant which is in ms. +func (obj *StatF) TarsSetTimeout(timeout int) { + obj.servant.TarsSetTimeout(timeout) +} - err = obj.servant.TarsInvoke(tarsCtx, 0, "reportMicMsg", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } +// TarsSetProtocol sets the protocol for the servant. +func (obj *StatF) TarsSetProtocol(p m.Protocol) { + obj.servant.TarsSetProtocol(p) +} - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } +// Endpoints returns all active endpoint.Endpoint +func (obj *StatF) Endpoints() []*endpoint.Endpoint { + return obj.servant.Endpoints() +} - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil +// ReportMicMsg is the proxy function for the method defined in the tars file, with the context +func (obj *StatF) ReportMicMsg(msg map[StatMicMsgHead]StatMicMsgBody, bFromClient bool, opts ...map[string]string) (int32, error) { + return obj.ReportMicMsgWithContext(context.Background(), msg, bFromClient, opts...) } // ReportMicMsgWithContext is the proxy function for the method defined in the tars file, with the context @@ -135,14 +75,14 @@ func (obj *StatF) ReportMicMsgWithContext(tarsCtx context.Context, msg map[StatM return ret, err } - for k1, v1 := range msg { + for k0, v0 := range msg { - err = k1.WriteBlock(buf, 0) + err = k0.WriteBlock(buf, 0) if err != nil { return ret, err } - err = v1.WriteBlock(buf, 1) + err = v0.WriteBlock(buf, 1) if err != nil { return ret, err } @@ -220,14 +160,14 @@ func (obj *StatF) ReportMicMsgOneWayWithContext(tarsCtx context.Context, msg map return ret, err } - for k2, v2 := range msg { + for k1, v1 := range msg { - err = k2.WriteBlock(buf, 0) + err = k1.WriteBlock(buf, 0) if err != nil { return ret, err } - err = v2.WriteBlock(buf, 1) + err = v1.WriteBlock(buf, 1) if err != nil { return ret, err } @@ -254,27 +194,6 @@ func (obj *StatF) ReportMicMsgOneWayWithContext(tarsCtx context.Context, msg map return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty @@ -282,79 +201,8 @@ func (obj *StatF) ReportMicMsgOneWayWithContext(tarsCtx context.Context, msg map } // ReportSampleMsg is the proxy function for the method defined in the tars file, with the context -func (obj *StatF) ReportSampleMsg(msg []StatSampleMsg, opts ...map[string]string) (ret int32, err error) { - var ( - length int32 - have bool - ty byte - ) - buf := codec.NewBuffer() - err = buf.WriteHead(codec.LIST, 1) - if err != nil { - return ret, err - } - - err = buf.WriteInt32(int32(len(msg)), 0) - if err != nil { - return ret, err - } - - for _, v := range msg { - - err = v.WriteBlock(buf, 0) - if err != nil { - return ret, err - } - - } - - var statusMap map[string]string - var contextMap map[string]string - if len(opts) == 1 { - contextMap = opts[0] - } else if len(opts) == 2 { - contextMap = opts[0] - statusMap = opts[1] - } - tarsResp := new(requestf.ResponsePacket) - tarsCtx := context.Background() - - err = obj.servant.TarsInvoke(tarsCtx, 0, "reportSampleMsg", buf.ToBytes(), statusMap, contextMap, tarsResp) - if err != nil { - return ret, err - } - - readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer)) - err = readBuf.ReadInt32(&ret, 0, true) - if err != nil { - return ret, err - } - - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } - _ = length - _ = have - _ = ty - return ret, nil +func (obj *StatF) ReportSampleMsg(msg []StatSampleMsg, opts ...map[string]string) (int32, error) { + return obj.ReportSampleMsgWithContext(context.Background(), msg, opts...) } // ReportSampleMsgWithContext is the proxy function for the method defined in the tars file, with the context @@ -474,48 +322,12 @@ func (obj *StatF) ReportSampleMsgOneWayWithContext(tarsCtx context.Context, msg return ret, err } - if len(opts) == 1 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - } else if len(opts) == 2 { - for k := range contextMap { - delete(contextMap, k) - } - for k, v := range tarsResp.Context { - contextMap[k] = v - } - for k := range statusMap { - delete(statusMap, k) - } - for k, v := range tarsResp.Status { - statusMap[k] = v - } - } _ = length _ = have _ = ty return ret, nil } -// SetServant sets servant for the service. -func (obj *StatF) SetServant(servant m.Servant) { - obj.servant = servant -} - -// TarsSetTimeout sets the timeout for the servant which is in ms. -func (obj *StatF) TarsSetTimeout(timeout int) { - obj.servant.TarsSetTimeout(timeout) -} - -// TarsSetProtocol sets the protocol for the servant. -func (obj *StatF) TarsSetProtocol(p m.Protocol) { - obj.servant.TarsSetProtocol(p) -} - type StatFServant interface { ReportMicMsg(msg map[StatMicMsgHead]StatMicMsgBody, bFromClient bool) (ret int32, err error) ReportSampleMsg(msg []StatSampleMsg) (ret int32, err error) @@ -553,21 +365,21 @@ func (obj *StatF) Dispatch(tarsCtx context.Context, val interface{}, tarsReq *re } msg = make(map[StatMicMsgHead]StatMicMsgBody) - for i3, e3 := int32(0), length; i3 < e3; i3++ { - var k3 StatMicMsgHead - var v3 StatMicMsgBody + for i2, e2 := int32(0), length; i2 < e2; i2++ { + var k2 StatMicMsgHead + var v2 StatMicMsgBody - err = k3.ReadBlock(readBuf, 0, false) + err = k2.ReadBlock(readBuf, 0, false) if err != nil { return err } - err = v3.ReadBlock(readBuf, 1, false) + err = v2.ReadBlock(readBuf, 1, false) if err != nil { return err } - msg[k3] = v3 + msg[k2] = v2 } err = readBuf.ReadBool(&bFromClient, 2, true) @@ -594,21 +406,21 @@ func (obj *StatF) Dispatch(tarsCtx context.Context, val interface{}, tarsReq *re } msg = make(map[StatMicMsgHead]StatMicMsgBody) - for i4, e4 := int32(0), length; i4 < e4; i4++ { - var k4 StatMicMsgHead - var v4 StatMicMsgBody + for i3, e3 := int32(0), length; i3 < e3; i3++ { + var k3 StatMicMsgHead + var v3 StatMicMsgBody - err = k4.ReadBlock(readBuf, 0, false) + err = k3.ReadBlock(readBuf, 0, false) if err != nil { return err } - err = v4.ReadBlock(readBuf, 1, false) + err = v3.ReadBlock(readBuf, 1, false) if err != nil { return err } - msg[k4] = v4 + msg[k3] = v3 } reqTup.GetBuffer("bFromClient", &tupBuffer) @@ -714,9 +526,9 @@ func (obj *StatF) Dispatch(tarsCtx context.Context, val interface{}, tarsReq *re } msg = make([]StatSampleMsg, length) - for i5, e5 := int32(0), length; i5 < e5; i5++ { + for i4, e4 := int32(0), length; i4 < e4; i4++ { - err = msg[i5].ReadBlock(readBuf, 0, false) + err = msg[i4].ReadBlock(readBuf, 0, false) if err != nil { return err } @@ -755,9 +567,9 @@ func (obj *StatF) Dispatch(tarsCtx context.Context, val interface{}, tarsReq *re } msg = make([]StatSampleMsg, length) - for i6, e6 := int32(0), length; i6 < e6; i6++ { + for i5, e5 := int32(0), length; i5 < e5; i5++ { - err = msg[i6].ReadBlock(readBuf, 0, false) + err = msg[i5].ReadBlock(readBuf, 0, false) if err != nil { return err }