update event response data structrue
This commit is contained in:
parent
4476501c05
commit
62d5a303bd
@ -11,17 +11,17 @@ spring.freemarker.suffix=
|
||||
spring.freemarker.cache=false
|
||||
|
||||
# Datasource
|
||||
yo.datasource.url=jdbc:mysql://172.18.4.35/yoqw?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
yo.datasource.url=jdbc:mysql://localhost/yoqw?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
yo.datasource.username=yoqw
|
||||
yo.datasource.password=yoqw_query!
|
||||
|
||||
# Datasource FreeSWITCH
|
||||
yo.fs.datasource.url=jdbc:mysql://172.18.4.35/fs_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
yo.fs.datasource.url=jdbc:mysql://localhost/fs_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
yo.fs.datasource.username=freeswitch
|
||||
yo.fs.datasource.password=RR!h5IpirsnJ
|
||||
|
||||
# Redis
|
||||
spring.redis.host=172.18.4.35
|
||||
spring.redis.host=localhost
|
||||
spring.redis.port=6379
|
||||
spring.redis.password=123456
|
||||
|
||||
@ -41,7 +41,7 @@ dubbo.application.qos-port=22222
|
||||
dubbo.application.qos-accept-foreign-ip=false
|
||||
|
||||
## Dubbo Registry
|
||||
dubbo.registry.address=zookeeper://172.18.4.35:2181
|
||||
dubbo.registry.address=zookeeper://localhost:2181
|
||||
dubbo.registry.file=${user.home}/dubbo-cache/${spring.application.name}/dubbo.cache
|
||||
|
||||
# Service Version
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.pudonghot.yo.model.agentevent;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.*;
|
||||
import java.io.Serializable;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.pudonghot.yo.openapi.controller;
|
||||
|
||||
import com.pudonghot.yo.openapi.response.RespAgentEvent;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
@ -11,7 +12,6 @@ import com.pudonghot.yo.model.exception.ErrorCode;
|
||||
import com.pudonghot.yo.model.agentevent.EventType;
|
||||
import com.pudonghot.yo.openapi.auth.SessionAbility;
|
||||
import com.pudonghot.yo.model.exception.AssertUtils;
|
||||
import com.pudonghot.yo.model.agentevent.AgentEvent;
|
||||
import com.pudonghot.yo.openapi.service.AgentService;
|
||||
import com.pudonghot.yo.service.CommonAgentStatusService;
|
||||
import com.pudonghot.yo.openapi.service.AgentEventService;
|
||||
@ -33,7 +33,7 @@ public class AgentEventController implements SessionAbility {
|
||||
private AgentEventService agentEventService;
|
||||
|
||||
@RequestMapping("/resource/agentevent/{account}")
|
||||
public DeferredResult<AgentEvent> agentEvent(
|
||||
public DeferredResult<RespAgentEvent> agentEvent(
|
||||
@PathVariable("account")
|
||||
final String account,
|
||||
@RequestParam("guid")
|
||||
@ -70,18 +70,18 @@ public class AgentEventController implements SessionAbility {
|
||||
* @param agentId agent id
|
||||
*/
|
||||
@GetMapping("/agent-event/fetch/{agentId}")
|
||||
public DeferredResult<AgentEvent> fetch(
|
||||
public DeferredResult<RespAgentEvent> fetch(
|
||||
@PathVariable("agentId")
|
||||
final Integer agentId) {
|
||||
final Agent agent = agentService.find(agentId);
|
||||
return agentEvent(agent, agentStatusService.findValidAgentStatus(agent));
|
||||
}
|
||||
|
||||
private DeferredResult<AgentEvent> agentEvent(
|
||||
private DeferredResult<RespAgentEvent> agentEvent(
|
||||
final Agent agent, final AgentStatus agentStatus) {
|
||||
|
||||
final String eventKey = agentStatus.getEventKey();
|
||||
final DeferredResult<AgentEvent> result = new DeferredResult<>();
|
||||
final DeferredResult<RespAgentEvent> result = new DeferredResult<>();
|
||||
result.onCompletion(() -> agentEventService.remove(eventKey, result));
|
||||
result.onTimeout(() -> agentEventService.remove(eventKey, result));
|
||||
agentEventService.put(eventKey, result);
|
||||
@ -92,4 +92,5 @@ public class AgentEventController implements SessionAbility {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.pudonghot.yo.openapi.response;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.pudonghot.yo.model.agentevent.AgentEvent;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Aug 14, 2020 23:08:46
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@ToString
|
||||
@RequiredArgsConstructor
|
||||
public class RespAgentEvent {
|
||||
private final AgentEvent event;
|
||||
}
|
@ -3,6 +3,7 @@ package com.pudonghot.yo.openapi.service;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
import com.pudonghot.yo.model.agentevent.EventType;
|
||||
import com.pudonghot.yo.model.agentevent.AgentEvent;
|
||||
import com.pudonghot.yo.openapi.response.RespAgentEvent;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
/**
|
||||
@ -17,7 +18,7 @@ public interface AgentEventService {
|
||||
* @param eventKey event key
|
||||
* @param result result
|
||||
*/
|
||||
void put(String eventKey, DeferredResult<AgentEvent> result);
|
||||
void put(String eventKey, DeferredResult<RespAgentEvent> result);
|
||||
|
||||
/**
|
||||
* remove result
|
||||
@ -25,7 +26,7 @@ public interface AgentEventService {
|
||||
* @param eventKey event key
|
||||
* @param result result
|
||||
*/
|
||||
void remove(String eventKey, DeferredResult<AgentEvent> result);
|
||||
void remove(String eventKey, DeferredResult<RespAgentEvent> result);
|
||||
|
||||
/**
|
||||
* publish agent event
|
||||
|
@ -22,6 +22,7 @@ import com.pudonghot.yo.model.agentevent.EventType;
|
||||
import com.pudonghot.yo.model.agentevent.AgentEvent;
|
||||
import org.redisson.api.map.event.EntryExpiredListener;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import com.pudonghot.yo.openapi.response.RespAgentEvent;
|
||||
import com.pudonghot.yo.service.CommonAgentStatusService;
|
||||
import com.pudonghot.yo.openapi.service.AgentEventService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -38,7 +39,7 @@ import static com.pudonghot.yo.model.agentevent.EventType.AgentOther_InService;
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AgentEventServiceImpl implements AgentEventService, InitializingBean, DisposableBean {
|
||||
private final Multimap<String, DeferredResult<AgentEvent>> WATCHED_RESULTS =
|
||||
private final Multimap<String, DeferredResult<RespAgentEvent>> WATCHED_RESULTS =
|
||||
Multimaps.synchronizedSetMultimap(HashMultimap.create());
|
||||
private final Map<Integer, Boolean> CACHE_SIGN_IN_SUCCESS =
|
||||
new ConcurrentHashMap<>(127);
|
||||
@ -66,7 +67,7 @@ public class AgentEventServiceImpl implements AgentEventService, InitializingBea
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void put(String eventKey, DeferredResult<AgentEvent> result) {
|
||||
public void put(String eventKey, DeferredResult<RespAgentEvent> result) {
|
||||
WATCHED_RESULTS.put(eventKey, result);
|
||||
}
|
||||
|
||||
@ -74,7 +75,7 @@ public class AgentEventServiceImpl implements AgentEventService, InitializingBea
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void remove(String eventKey, DeferredResult<AgentEvent> result) {
|
||||
public void remove(String eventKey, DeferredResult<RespAgentEvent> result) {
|
||||
WATCHED_RESULTS.remove(eventKey, result);
|
||||
}
|
||||
|
||||
@ -111,11 +112,11 @@ public class AgentEventServiceImpl implements AgentEventService, InitializingBea
|
||||
|
||||
final String eventKey = agentStatus.getEventKey();
|
||||
if (StringUtils.isNotBlank(eventKey)) {
|
||||
final Collection<DeferredResult<AgentEvent>> results =
|
||||
final Collection<DeferredResult<RespAgentEvent>> results =
|
||||
WATCHED_RESULTS.get(eventKey);
|
||||
if (results != null) {
|
||||
for (final DeferredResult<AgentEvent> result : results) {
|
||||
result.setResult(event);
|
||||
for (final DeferredResult<RespAgentEvent> result : results) {
|
||||
result.setResult(new RespAgentEvent(event));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -11,17 +11,17 @@ tigon.web.jsonview.code-type=string
|
||||
tigon.web.jsonview.message-key=message
|
||||
|
||||
# Datasource
|
||||
yo.datasource.url=jdbc:mysql://172.18.4.35/yoqw?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
yo.datasource.url=jdbc:mysql://localhost/yoqw?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
yo.datasource.username=yoqw
|
||||
yo.datasource.password=yoqw_query!
|
||||
|
||||
# Datasource FreeSWITCH
|
||||
yo.fs.datasource.url=jdbc:mysql://172.18.4.35/fs_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
yo.fs.datasource.url=jdbc:mysql://localhost/fs_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
yo.fs.datasource.username=freeswitch
|
||||
yo.fs.datasource.password=RR!h5IpirsnJ
|
||||
|
||||
# Redis
|
||||
spring.redis.host=172.18.4.35
|
||||
spring.redis.host=localhost
|
||||
spring.redis.port=6379
|
||||
spring.redis.password=123456
|
||||
|
||||
@ -31,6 +31,7 @@ yo.openapi.default-tenant=GOBLIN
|
||||
# Dubbo
|
||||
|
||||
## Dubbo Registry
|
||||
dubbo.registry.address=zookeeper://172.18.4.35:2181
|
||||
dubbo.registry.address=zookeeper://localhost:2181
|
||||
dubbo.registry.file=${user.home}/dubbo-cache/${spring.application.name}/dubbo.cache
|
||||
yo.fsagent.dubbo.service.version=1.0.0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user