Toggle navigation
Toggle navigation
This project
Loading...
Sign in
jiujian
/
client-customer-order-service
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhuyifan
2025-04-22 17:54:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
65bd4fe34583ee324eeca5eef1c3fc2a2efd2e62
65bd4fe3
1 parent
e39667f0
fix
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
7 deletions
src/main/java/com/tianting/infoloop/service/grpc/MealOrderGrpcService.java
src/main/java/com/tianting/infoloop/tracing/GrpcServerInterceptor.java
src/main/java/com/tianting/infoloop/tracing/MyContextualizedServerCallListener.java
src/main/java/com/tianting/infoloop/service/grpc/MealOrderGrpcService.java
View file @
65bd4fe
...
...
@@ -247,12 +247,12 @@ public class MealOrderGrpcService extends MealOrderServiceRpcGrpc.MealOrderServi
queryWrapper
.
eq
(
MealOrder:
:
getEnterpriseId
,
request
.
getEnterpriseId
());
queryWrapper
.
in
(!
request
.
getDinerIdsList
().
isEmpty
(),
MealOrder:
:
getDinerId
,
request
.
getDinerIdsList
());
LocalDate
today
=
LocalDate
.
now
();
LocalDate
nextMonday
=
today
.
with
(
TemporalAdjusters
.
next
(
DayOfWeek
.
MONDAY
));
LocalDateTime
nextMondayStart
=
LocalDateTime
.
of
(
next
Monday
,
LocalTime
.
MIN
);
LocalDate
nextSunday
=
nextMonday
.
plusDays
(
6
);
LocalDateTime
nextSundayEnd
=
LocalDateTime
.
of
(
next
Sunday
,
LocalTime
.
MAX
);
queryWrapper
.
ge
(
MealOrder:
:
getReserveDate
,
next
MondayStart
);
queryWrapper
.
lt
(
MealOrder:
:
getReserveDate
,
next
SundayEnd
);
LocalDate
thisMonday
=
today
.
with
(
TemporalAdjusters
.
previousOrSame
(
DayOfWeek
.
MONDAY
));
LocalDateTime
thisMondayStart
=
LocalDateTime
.
of
(
this
Monday
,
LocalTime
.
MIN
);
LocalDate
thisSunday
=
today
.
with
(
TemporalAdjusters
.
nextOrSame
(
DayOfWeek
.
SUNDAY
)
);
LocalDateTime
thisSundayEnd
=
LocalDateTime
.
of
(
this
Sunday
,
LocalTime
.
MAX
);
queryWrapper
.
ge
(
MealOrder:
:
getReserveDate
,
this
MondayStart
);
queryWrapper
.
lt
(
MealOrder:
:
getReserveDate
,
this
SundayEnd
);
final
var
mealOrders
=
mealOrderService
.
list
(
queryWrapper
);
if
(!
mealOrders
.
isEmpty
())
{
for
(
final
var
mealOrder
:
mealOrders
)
{
...
...
src/main/java/com/tianting/infoloop/tracing/GrpcServerInterceptor.java
View file @
65bd4fe
...
...
@@ -4,7 +4,6 @@ import brave.Span;
import
brave.Tracing
;
import
brave.baggage.BaggagePropagation
;
import
brave.propagation.Propagation
;
import
com.tianting.infoloop.constants.ConfigConstants
;
import
io.grpc.Context
;
import
io.grpc.ForwardingServerCall
;
import
io.grpc.Grpc
;
...
...
@@ -14,6 +13,7 @@ import io.grpc.ServerCallHandler;
import
io.grpc.ServerInterceptor
;
import
io.grpc.Status
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.MDC
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Component
;
...
...
@@ -24,6 +24,9 @@ import java.util.Objects;
import
static
com
.
tianting
.
infoloop
.
constants
.
ConfigConstants
.
BRAVE_PROPAGATION_DEBUG_FIELD
;
import
static
com
.
tianting
.
infoloop
.
constants
.
ConfigConstants
.
ENTERPRISE_ID_KEY
;
import
static
com
.
tianting
.
infoloop
.
constants
.
ConfigConstants
.
LOGGING_PARENT_TRACING_ID
;
import
static
com
.
tianting
.
infoloop
.
constants
.
ConfigConstants
.
LOGGING_TRACING_ID
;
import
static
com
.
tianting
.
infoloop
.
constants
.
ConfigConstants
.
LOGGING_UNIQUE_ID
;
import
static
com
.
tianting
.
infoloop
.
constants
.
ConfigConstants
.
SOURCE_KEY
;
import
static
com
.
tianting
.
infoloop
.
constants
.
ConfigConstants
.
USER_ID_KEY
;
...
...
@@ -71,6 +74,9 @@ public class GrpcServerInterceptor implements ServerInterceptor {
span
.
remoteIpAndPort
(
remoteAddressAndPort
[
0
],
Integer
.
parseInt
(
remoteAddressAndPort
[
1
]));
span
.
name
(
fullMethodName
);
span
.
start
();
MDC
.
put
(
LOGGING_TRACING_ID
,
span
.
context
().
traceIdString
());
MDC
.
put
(
LOGGING_UNIQUE_ID
,
span
.
context
().
spanIdString
());
MDC
.
put
(
LOGGING_PARENT_TRACING_ID
,
span
.
context
().
parentIdString
());
final
var
scope
=
tracing
.
currentTraceContext
().
newScope
(
span
.
context
());
final
var
listener
=
next
.
startCall
(
new
ForwardingServerCall
.
SimpleForwardingServerCall
<>(
call
)
{
...
...
@@ -106,6 +112,7 @@ public class GrpcServerInterceptor implements ServerInterceptor {
}
scope
.
close
();
span
.
finish
();
MDC
.
clear
();
}
},
headers
);
Context
context
=
setUserContextFromHeaders
(
headers
,
fullMethodName
);
...
...
src/main/java/com/tianting/infoloop/tracing/MyContextualizedServerCallListener.java
View file @
65bd4fe
...
...
@@ -9,6 +9,7 @@ import io.grpc.Context;
import
io.grpc.ForwardingServerCallListener
;
import
io.grpc.ServerCall
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.MDC
;
import
static
com
.
tianting
.
infoloop
.
constants
.
ConfigConstants
.
BRAVE_PROPAGATION_DEBUG_FIELD
;
...
...
@@ -67,6 +68,7 @@ public class MyContextualizedServerCallListener<ReqT> extends ForwardingServerCa
span
.
error
(
e
);
scope
.
close
();
span
.
finish
();
MDC
.
clear
();
throw
e
;
}
finally
{
context
.
detach
(
previous
);
...
...
@@ -82,6 +84,7 @@ public class MyContextualizedServerCallListener<ReqT> extends ForwardingServerCa
span
.
error
(
e
);
scope
.
close
();
span
.
finish
();
MDC
.
clear
();
throw
e
;
}
finally
{
context
.
detach
(
previous
);
...
...
Please
register
or
login
to post a comment