use of com.alipay.sofa.rpc.registry.mesh.model.PublishServiceResult in project sofa-rpc by sofastack.
the class MeshApiClient method publishService.
public boolean publishService(PublishServiceRequest publishServiceRequest) {
final String json = JSON.toJSONString(publishServiceRequest);
String result = httpPost(MeshEndpoint.PUBLISH, json);
if (!StringUtils.equals(result, errorMessage)) {
final PublishServiceResult parse = JSON.parseObject(result, PublishServiceResult.class);
if (parse.isSuccess()) {
return true;
}
return false;
} else {
return false;
}
}
use of com.alipay.sofa.rpc.registry.mesh.model.PublishServiceResult in project sofa-rpc by sofastack.
the class MeshRegistryTest method setUp.
@Before
public void setUp() {
httpMockServer = new HttpMockServer();
httpMockServer.initSever(7654);
ApplicationInfoResult applicationInfoResult = new ApplicationInfoResult();
applicationInfoResult.setSuccess(true);
httpMockServer.addMockPath(MeshEndpoint.CONFIGS, JSON.toJSONString(applicationInfoResult));
PublishServiceResult publishServiceResult = new PublishServiceResult();
publishServiceResult.setSuccess(true);
httpMockServer.addMockPath(MeshEndpoint.PUBLISH, JSON.toJSONString(publishServiceResult));
SubscribeServiceResult subscribeServiceResult = new SubscribeServiceResult();
subscribeServiceResult.setSuccess(true);
List<String> datas = new ArrayList<String>();
datas.add("127.0.0.1:12200?v=4.0&p=1");
datas.add("127.0.0.1:12201?v=4.0&p=1");
subscribeServiceResult.setDatas(datas);
httpMockServer.addMockPath(MeshEndpoint.SUBCRIBE, JSON.toJSONString(subscribeServiceResult));
UnPublishServiceResult unPublishServiceResult = new UnPublishServiceResult();
unPublishServiceResult.setSuccess(true);
httpMockServer.addMockPath(MeshEndpoint.UN_PUBLISH, JSON.toJSONString(unPublishServiceResult));
UnSubscribeServiceResult unSubscribeServiceResult = new UnSubscribeServiceResult();
unSubscribeServiceResult.setSuccess(true);
httpMockServer.addMockPath(MeshEndpoint.UN_SUBCRIBE, JSON.toJSONString(unSubscribeServiceResult));
httpMockServer.start();
registryConfig = new RegistryConfig().setProtocol("mesh").setSubscribe(true).setRegister(true).setAddress("http://localhost:7654");
registry = (MeshRegistry) RegistryFactory.getRegistry(registryConfig);
registry.init();
registry.start();
}
use of com.alipay.sofa.rpc.registry.mesh.model.PublishServiceResult in project sofa-rpc by sofastack.
the class MeshApiClientTest method before.
@Before
public void before() {
httpMockServer = new HttpMockServer();
meshApiClient = new MeshApiClient("http://localhost:7654");
httpMockServer.initSever(7654);
ApplicationInfoResult applicationInfoResult = new ApplicationInfoResult();
applicationInfoResult.setSuccess(true);
httpMockServer.addMockPath(MeshEndpoint.CONFIGS, JSON.toJSONString(applicationInfoResult));
PublishServiceResult publishServiceResult = new PublishServiceResult();
publishServiceResult.setSuccess(true);
httpMockServer.addMockPath(MeshEndpoint.PUBLISH, JSON.toJSONString(publishServiceResult));
SubscribeServiceResult subscribeServiceResult = new SubscribeServiceResult();
subscribeServiceResult.setSuccess(true);
httpMockServer.addMockPath(MeshEndpoint.SUBCRIBE, JSON.toJSONString(subscribeServiceResult));
UnPublishServiceResult unPublishServiceResult = new UnPublishServiceResult();
unPublishServiceResult.setSuccess(true);
httpMockServer.addMockPath(MeshEndpoint.UN_PUBLISH, JSON.toJSONString(unPublishServiceResult));
UnSubscribeServiceResult unSubscribeServiceResult = new UnSubscribeServiceResult();
unSubscribeServiceResult.setSuccess(true);
httpMockServer.addMockPath(MeshEndpoint.UN_SUBCRIBE, JSON.toJSONString(unSubscribeServiceResult));
httpMockServer.start();
}
Aggregations