@@ -13,8 +13,10 @@ import (
1313 "sync"
1414 "time"
1515
16+ "crypto/sha256"
1617 "github.com/cenkalti/backoff"
1718 "github.com/go-chassis/go-chassis/pkg/httpclient"
19+ "github.com/go-chassis/go-sc-client/proto"
1820 "github.com/go-mesh/openlogging"
1921 "github.com/gorilla/websocket"
2022)
@@ -270,10 +272,10 @@ func (c *RegistryClient) GetProviders(consumer string, opts ...CallOption) (*Mic
270272 providersURL := c .formatURL (fmt .Sprintf ("%s%s/%s/providers" , MSAPIPath , MicroservicePath , consumer ), nil , copts )
271273 resp , err := c .HTTPDo ("GET" , providersURL , nil , nil )
272274 if err != nil {
273- return nil , fmt .Errorf ("Get Providers failed, error: %s, MicroServiceid: %s" , err , consumer )
275+ return nil , fmt .Errorf ("get Providers failed, error: %s, MicroServiceid: %s" , err , consumer )
274276 }
275277 if resp == nil {
276- return nil , fmt .Errorf ("Get Providers failed, response is empty, MicroServiceid: %s" , consumer )
278+ return nil , fmt .Errorf ("get Providers failed, response is empty, MicroServiceid: %s" , consumer )
277279 }
278280 var body []byte
279281 body , err = ioutil .ReadAll (resp .Body )
@@ -312,7 +314,7 @@ func (c *RegistryClient) AddDependencies(request *MircroServiceDependencyRequest
312314 return fmt .Errorf ("AddDependencies failed, response is empty" )
313315 }
314316 if resp .StatusCode != http .StatusOK {
315- return NewCommonException ("add microservice dependencies failed. response StatusCode: %d, response body: %s" ,
317+ return NewCommonException ("add micro service dependencies failed. response StatusCode: %d, response body: %s" ,
316318 resp .StatusCode , string (body ))
317319 }
318320 return nil
@@ -321,12 +323,20 @@ func (c *RegistryClient) AddDependencies(request *MircroServiceDependencyRequest
321323// AddSchemas adds a schema contents to the services registered in service-center
322324func (c * RegistryClient ) AddSchemas (microServiceID , schemaName , schemaInfo string ) error {
323325 if microServiceID == "" {
324- return errors .New ("invalid microserviceID " )
326+ return errors .New ("invalid micro service ID " )
325327 }
326328
327329 schemaURL := c .formatURL (fmt .Sprintf ("%s%s/%s%s/%s" , MSAPIPath , MicroservicePath , microServiceID , SchemaPath , schemaName ), nil , nil )
328- request := & MicroServiceInstanceSchemaUpdateRequest {
329- SchemaContent : schemaInfo ,
330+ h := sha256 .New ()
331+ _ , err := h .Write ([]byte (schemaInfo ))
332+ if err != nil {
333+ return err
334+ }
335+ request := & proto.ModifySchemaRequest {
336+ SchemaId : schemaName ,
337+ ServiceId : microServiceID ,
338+ Schema : schemaInfo ,
339+ Summary : fmt .Sprintf ("%x" , h .Sum (nil )),
330340 }
331341 body , err := json .Marshal (request )
332342 if err != nil {
@@ -339,7 +349,7 @@ func (c *RegistryClient) AddSchemas(microServiceID, schemaName, schemaInfo strin
339349 }
340350
341351 if resp == nil {
342- return fmt .Errorf ("Addschemas failed, response is empty" )
352+ return fmt .Errorf ("add schemas failed, response is empty" )
343353 }
344354
345355 if resp .StatusCode != http .StatusOK {
0 commit comments