parent
f58fdd14a4
commit
c2a0574aa3
@ -0,0 +1,26 @@ |
||||
package rition.backend.configure; |
||||
|
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.data.redis.serializer.RedisSerializer; |
||||
|
||||
@Configuration |
||||
public class RedisTemplateConfigure { |
||||
|
||||
@Bean |
||||
public RedisTemplate redisTemplate(LettuceConnectionFactory connectionFactory) { |
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); |
||||
redisTemplate.setConnectionFactory(connectionFactory); |
||||
|
||||
redisTemplate.setKeySerializer(RedisSerializer.string()); |
||||
redisTemplate.setValueSerializer(RedisSerializer.json()); |
||||
redisTemplate.setHashKeySerializer(RedisSerializer.string()); |
||||
redisTemplate.setDefaultSerializer(RedisSerializer.json()); |
||||
|
||||
redisTemplate.afterPropertiesSet(); |
||||
|
||||
return redisTemplate; |
||||
} |
||||
} |
@ -1,7 +1,13 @@ |
||||
server: |
||||
port: 22019 |
||||
port: 8000 |
||||
servlet: |
||||
context-path: /api |
||||
|
||||
spring: |
||||
profiles: |
||||
include: collector |
||||
include: collector |
||||
data: |
||||
redis: |
||||
host: ${REDIS_HOST:127.0.0.1} |
||||
port: ${REDIS_PORT:6379} |
||||
password: ${REDIS_PASSWORD:Test2333!} |
||||
|
@ -0,0 +1,67 @@ |
||||
package rition.common.data.dto.log; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.time.Duration; |
||||
|
||||
@Data |
||||
@Builder |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class RequestProcessTraceRecord { |
||||
private String requestId; |
||||
|
||||
private OperationStatus status; |
||||
|
||||
private String message; |
||||
|
||||
private Exception exception; |
||||
|
||||
private long cost; |
||||
|
||||
private Object extra; |
||||
|
||||
public static RequestProcessTraceRecord success(String requestId, String message, Object extraData) { |
||||
return RequestProcessTraceRecord.builder() |
||||
.requestId(requestId) |
||||
.message(message) |
||||
.extra(extraData) |
||||
.status(OperationStatus.OK) |
||||
.build(); |
||||
} |
||||
|
||||
public static RequestProcessTraceRecord success(String requestId, |
||||
String message, |
||||
long cost, |
||||
Object extraData) { |
||||
return RequestProcessTraceRecord.builder() |
||||
.requestId(requestId) |
||||
.message(message) |
||||
.extra(extraData) |
||||
.cost(cost) |
||||
.status(OperationStatus.OK) |
||||
.build(); |
||||
} |
||||
|
||||
public enum OperationStatus { |
||||
/** |
||||
* 成功 |
||||
*/ |
||||
OK, |
||||
|
||||
/** |
||||
* 失败 |
||||
*/ |
||||
FAIL, |
||||
|
||||
/** |
||||
* 部分完成 |
||||
*/ |
||||
PARTIALLY_FINISHED |
||||
} |
||||
} |
Loading…
Reference in new issue