Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
e75ef096
Unverified
Commit
e75ef096
authored
Mar 14, 2025
by
Amir Ehsandar
Committed by
GitHub
Mar 14, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: implement grpc health service checking database connection (#4499)
parent
fc7dc587
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
health_service.go
server/router/api/v1/health_service.go
+21
-0
v1.go
server/router/api/v1/v1.go
+4
-0
No files found.
server/router/api/v1/health_service.go
0 → 100644
View file @
e75ef096
package
v1
import
(
"context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/status"
"github.com/usememos/memos/store"
)
func
(
s
*
APIV1Service
)
Check
(
ctx
context
.
Context
,
_
*
grpc_health_v1
.
HealthCheckRequest
)
(
*
grpc_health_v1
.
HealthCheckResponse
,
error
)
{
history
,
err
:=
s
.
Store
.
GetDriver
()
.
FindMigrationHistoryList
(
ctx
,
&
store
.
FindMigrationHistory
{})
if
err
!=
nil
||
len
(
history
)
==
0
{
return
nil
,
status
.
Errorf
(
codes
.
Unavailable
,
"not available"
)
}
return
&
grpc_health_v1
.
HealthCheckResponse
{
Status
:
grpc_health_v1
.
HealthCheckResponse_SERVING
},
nil
}
server/router/api/v1/v1.go
View file @
e75ef096
...
...
@@ -11,6 +11,7 @@ import (
"github.com/labstack/echo/v4/middleware"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/reflection"
v1pb
"github.com/usememos/memos/proto/gen/api/v1"
...
...
@@ -19,6 +20,8 @@ import (
)
type
APIV1Service
struct
{
grpc_health_v1
.
UnimplementedHealthServer
v1pb
.
UnimplementedWorkspaceServiceServer
v1pb
.
UnimplementedWorkspaceSettingServiceServer
v1pb
.
UnimplementedAuthServiceServer
...
...
@@ -46,6 +49,7 @@ func NewAPIV1Service(secret string, profile *profile.Profile, store *store.Store
Store
:
store
,
grpcServer
:
grpcServer
,
}
grpc_health_v1
.
RegisterHealthServer
(
grpcServer
,
apiv1Service
)
v1pb
.
RegisterWorkspaceServiceServer
(
grpcServer
,
apiv1Service
)
v1pb
.
RegisterWorkspaceSettingServiceServer
(
grpcServer
,
apiv1Service
)
v1pb
.
RegisterAuthServiceServer
(
grpcServer
,
apiv1Service
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment