From c4b3be52911e257876aabddf19789539ff478d3a Mon Sep 17 00:00:00 2001 From: r-patali Date: Tue, 6 Aug 2019 16:58:18 -0700 Subject: [PATCH] updating clientconfig struct --- codegen/client.go | 26 ++++++------------- codegen/client_test.go | 14 +++++----- codegen/type_converter.go | 2 +- docs/client_config_schema.json | 4 +-- .../clients/bar/client-config.json | 4 +-- .../clients/baz/client-config.yaml | 4 +-- .../clients/contacts/client-config.yaml | 4 +-- .../clients/corge-http/client-config.yaml | 4 +-- .../clients/corge/client-config.yaml | 4 +-- .../clients/google-now/client-config.yaml | 4 +-- .../clients/multi/client-config.yaml | 4 +-- .../clients/withexceptions/client-config.json | 4 +-- 12 files changed, 34 insertions(+), 44 deletions(-) diff --git a/codegen/client.go b/codegen/client.go index 046d82dc3..13076a368 100644 --- a/codegen/client.go +++ b/codegen/client.go @@ -34,18 +34,8 @@ type clientConfig interface { h *PackageHelper) (*ClientSpec, error) } -// ClientThriftConfig is the "config" field in the client-config.yaml for http -// client and tchannel client. -type ClientThriftConfig struct { - ExposedMethods map[string]string `yaml:"exposedMethods" json:"exposedMethods" validate:"exposedMethods"` - ThriftFile string `yaml:"thriftFile" json:"thriftFile" validate:"nonzero"` - ThriftFileSha string `yaml:"thriftFileSha,omitempty" json:"thriftFileSha"` - SidecarRouter string `yaml:"sidecarRouter" json:"sidecarRouter"` - Fixture *Fixture `yaml:"fixture,omitempty" json:"fixture"` -} - -// ClientIDLConfig is the "config" field in the client-config.yaml for gRPC clients. -// This struct is generic and can be used to replace HTTP/TChannel client config as well. +// ClientIDLConfig is the "config" field in the client-config.yaml for +// HTTP/TChannel/gRPC clients. type ClientIDLConfig struct { ExposedMethods map[string]string `yaml:"exposedMethods" json:"exposedMethods" validate:"exposedMethods"` IDLFile string `yaml:"idlFile" json:"idlFile" validate:"nonzero"` @@ -95,8 +85,8 @@ func validateExposedMethods(v interface{}, param string) error { // HTTPClientConfig represents the "config" field for a HTTP client-config.yaml type HTTPClientConfig struct { ClassConfigBase `yaml:",inline" json:",inline"` - Dependencies Dependencies `yaml:"dependencies,omitempty" json:"dependencies"` - Config *ClientThriftConfig `yaml:"config" json:"config" validate:"nonzero"` + Dependencies Dependencies `yaml:"dependencies,omitempty" json:"dependencies"` + Config *ClientIDLConfig `yaml:"config" json:"config" validate:"nonzero"` } func newHTTPClientConfig(raw []byte) (*HTTPClientConfig, error) { @@ -117,12 +107,12 @@ func newHTTPClientConfig(raw []byte) (*HTTPClientConfig, error) { func newClientSpec( clientType string, - config *ClientThriftConfig, + config *ClientIDLConfig, instance *ModuleInstance, h *PackageHelper, annotate bool, ) (*ClientSpec, error) { - thriftFile := filepath.Join(h.ThriftIDLPath(), config.ThriftFile) + thriftFile := filepath.Join(h.ThriftIDLPath(), config.IDLFile) mspec, err := NewModuleSpec(thriftFile, annotate, false, h) if err != nil { @@ -161,8 +151,8 @@ func (c *HTTPClientConfig) NewClientSpec( // TChannelClientConfig represents the "config" field for a TChannel client-config.yaml type TChannelClientConfig struct { ClassConfigBase `yaml:",inline" json:",inline"` - Dependencies Dependencies `yaml:"dependencies,omitempty" json:"dependencies"` - Config *ClientThriftConfig `yaml:"config" json:"config" validate:"nonzero"` + Dependencies Dependencies `yaml:"dependencies,omitempty" json:"dependencies"` + Config *ClientIDLConfig `yaml:"config" json:"config" validate:"nonzero"` } func newTChannelClientConfig(raw []byte) (*TChannelClientConfig, error) { diff --git a/codegen/client_test.go b/codegen/client_test.go index 149961d19..d1082f111 100644 --- a/codegen/client_test.go +++ b/codegen/client_test.go @@ -150,7 +150,7 @@ config: assert.Error(t, err) assert.Equal( t, - fmt.Sprintf("%s client config validation failed: Config.ThriftFile: zero value", clientType), + fmt.Sprintf("%s client config validation failed: Config.IDLFile: zero value", clientType), err.Error()) } @@ -273,12 +273,12 @@ func TestNewClientConfigGetHTTPClient(t *testing.T) { Dependencies: Dependencies{ Client: []string{"a", "b"}, }, - Config: &ClientThriftConfig{ + Config: &ClientIDLConfig{ ExposedMethods: map[string]string{ "a": "method", }, - ThriftFileSha: "thriftFileSha", - ThriftFile: "clients/bar/bar.thrift", + IDLFileSha: "thriftFileSha", + IDLFile: "clients/bar/bar.thrift", SidecarRouter: "sidecar", Fixture: &Fixture{ ImportPath: "import", @@ -302,12 +302,12 @@ func TestNewClientConfigGetTChannelClient(t *testing.T) { Dependencies: Dependencies{ Client: []string{"a", "b"}, }, - Config: &ClientThriftConfig{ + Config: &ClientIDLConfig{ ExposedMethods: map[string]string{ "a": "method", }, - ThriftFileSha: "thriftFileSha", - ThriftFile: "clients/bar/bar.thrift", + IDLFileSha: "thriftFileSha", + IDLFile: "clients/bar/bar.thrift", SidecarRouter: "sidecar", Fixture: &Fixture{ ImportPath: "import", diff --git a/codegen/type_converter.go b/codegen/type_converter.go index ce85337f7..702878429 100644 --- a/codegen/type_converter.go +++ b/codegen/type_converter.go @@ -915,7 +915,7 @@ func (c *TypeConverter) genStructConverter( // toField.Type.TypeCode().String(), toField.Name, // ) - // pkgName, err := h.TypePackageName(toField.Type.ThriftFile()) + // pkgName, err := h.TypePackageName(toField.Type.IDLFile()) // if err != nil { // return nil, err // } diff --git a/docs/client_config_schema.json b/docs/client_config_schema.json index e00af5e73..69e3f6fac 100644 --- a/docs/client_config_schema.json +++ b/docs/client_config_schema.json @@ -25,14 +25,14 @@ "config": { "type": "object", "properties": { - "thriftFile": { + "idlFile": { "type": "string", "description": "Path to client thrift file, relative to idl path", "examples": [ "clients/contacts/contacts.thrift" ] }, - "thriftFileSha": { + "idlFileSha": { "type": "string", "description": "Sha of the thrift file, reserved but currently not used", "examples": [ diff --git a/examples/example-gateway/clients/bar/client-config.json b/examples/example-gateway/clients/bar/client-config.json index 54da2c8a3..b6841b907 100644 --- a/examples/example-gateway/clients/bar/client-config.json +++ b/examples/example-gateway/clients/bar/client-config.json @@ -2,8 +2,8 @@ "name": "bar", "type": "http", "config": { - "thriftFile": "clients/bar/bar.thrift", - "thriftFileSha": "{{placeholder}}", + "idlFile": "clients/bar/bar.thrift", + "idlFileSha": "{{placeholder}}", "exposedMethods": { "Normal": "Bar::normal", "NormalRecur": "Bar::normalRecur", diff --git a/examples/example-gateway/clients/baz/client-config.yaml b/examples/example-gateway/clients/baz/client-config.yaml index d96a1fda1..6183e761e 100644 --- a/examples/example-gateway/clients/baz/client-config.yaml +++ b/examples/example-gateway/clients/baz/client-config.yaml @@ -27,8 +27,8 @@ config: TransHeadersNoReq: SimpleService::transHeadersNoReq TransHeadersType: SimpleService::transHeadersType URLTest: SimpleService::urlTest - thriftFile: clients/baz/baz.thrift - thriftFileSha: '{{placeholder}}' + idlFile: clients/baz/baz.thrift + idlFileSha: '{{placeholder}}' genTestServer: true name: baz type: tchannel diff --git a/examples/example-gateway/clients/contacts/client-config.yaml b/examples/example-gateway/clients/contacts/client-config.yaml index bfdfcdde7..a83a1e2dd 100644 --- a/examples/example-gateway/clients/contacts/client-config.yaml +++ b/examples/example-gateway/clients/contacts/client-config.yaml @@ -7,7 +7,7 @@ config: scenarios: SaveContacts: - success - thriftFile: clients/contacts/contacts.thrift - thriftFileSha: '{{placeholder}}' + idlFile: clients/contacts/contacts.thrift + idlFileSha: '{{placeholder}}' name: contacts type: http diff --git a/examples/example-gateway/clients/corge-http/client-config.yaml b/examples/example-gateway/clients/corge-http/client-config.yaml index f1fe43dcb..9889923ce 100644 --- a/examples/example-gateway/clients/corge-http/client-config.yaml +++ b/examples/example-gateway/clients/corge-http/client-config.yaml @@ -2,7 +2,7 @@ config: exposedMethods: EchoString: Corge::echoString sidecarRouter: default - thriftFile: clients/corge/corge.thrift - thriftFileSha: '{{placeholder}}' + idlFile: clients/corge/corge.thrift + idlFileSha: '{{placeholder}}' name: corge-http type: http diff --git a/examples/example-gateway/clients/corge/client-config.yaml b/examples/example-gateway/clients/corge/client-config.yaml index 4fe1e8fc3..6bbbcc7da 100644 --- a/examples/example-gateway/clients/corge/client-config.yaml +++ b/examples/example-gateway/clients/corge/client-config.yaml @@ -2,7 +2,7 @@ config: exposedMethods: EchoString: Corge::echoString sidecarRouter: default - thriftFile: clients/corge/corge.thrift - thriftFileSha: '{{placeholder}}' + idlFile: clients/corge/corge.thrift + idlFileSha: '{{placeholder}}' name: corge type: tchannel diff --git a/examples/example-gateway/clients/google-now/client-config.yaml b/examples/example-gateway/clients/google-now/client-config.yaml index dc5c2d126..550d316e6 100644 --- a/examples/example-gateway/clients/google-now/client-config.yaml +++ b/examples/example-gateway/clients/google-now/client-config.yaml @@ -2,7 +2,7 @@ config: exposedMethods: AddCredentials: GoogleNowService::addCredentials CheckCredentials: GoogleNowService::checkCredentials - thriftFile: clients/googlenow/googlenow.thrift - thriftFileSha: '{{placeholder}}' + idlFile: clients/googlenow/googlenow.thrift + idlFileSha: '{{placeholder}}' name: google-now type: http diff --git a/examples/example-gateway/clients/multi/client-config.yaml b/examples/example-gateway/clients/multi/client-config.yaml index 8335a4f2d..313fae1f1 100644 --- a/examples/example-gateway/clients/multi/client-config.yaml +++ b/examples/example-gateway/clients/multi/client-config.yaml @@ -2,7 +2,7 @@ config: exposedMethods: HelloA: ServiceABack::hello HelloB: ServiceBBack::hello - thriftFile: clients/multi/multi.thrift - thriftFileSha: '{{placeholder}}' + idlFile: clients/multi/multi.thrift + idlFileSha: '{{placeholder}}' name: multi type: http diff --git a/examples/example-gateway/clients/withexceptions/client-config.json b/examples/example-gateway/clients/withexceptions/client-config.json index 8d08c0c99..26ab0b167 100644 --- a/examples/example-gateway/clients/withexceptions/client-config.json +++ b/examples/example-gateway/clients/withexceptions/client-config.json @@ -2,8 +2,8 @@ "name": "withexceptions", "type": "http", "config": { - "thriftFile": "clients/withexceptions/withexceptions.thrift", - "thriftFileSha": "{{placeholder}}", + "idlFile": "clients/withexceptions/withexceptions.thrift", + "idlFileSha": "{{placeholder}}", "exposedMethods": { "Func1": "WithExceptions::Func1" }