Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 4525cb4

Browse files
author
henry.hj
committed
define new apis
+ /peer/network + /peer/heartbeat Signed-off-by: henry.hj <[email protected]>
1 parent 44506bf commit 4525cb4

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

apis/swagger.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ paths:
664664
200:
665665
description: "no error"
666666
schema:
667-
$ref: "#/definitions/ResultInfo"
667+
$ref: "#/definitions/HeartBeatResponse"
668668
500:
669669
$ref: "#/responses/500ErrorResponse"
670670

@@ -1511,6 +1511,27 @@ definitions:
15111511
This dfget is treated a client and carries a client ID.
15121512
Thus, multiple dfget processes on the same peer have different CIDs.
15131513
1514+
HeartBeatResponse:
1515+
type: "object"
1516+
description: ""
1517+
properties:
1518+
version:
1519+
type: "string"
1520+
description: |
1521+
The version of supernode. If supernode restarts, version should be different, so dfdaemon could know
1522+
the restart of supernode.
1523+
needRegister:
1524+
type: "boolean"
1525+
description: |
1526+
If peer do not register in supernode, set needRegister to be true, else set to be false.
1527+
seedTaskIDs:
1528+
type: "array"
1529+
description: |
1530+
The array of seed taskID which now are selected as seed for the peer. If peer have other seed file which
1531+
is not included in the array, these seed file should be weed out.
1532+
items:
1533+
type: "string"
1534+
15141535
ErrorResponse:
15151536
type: "object"
15161537
description: |

apis/types/heart_beat_response.go

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

supernode/server/0.3_bridge.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,11 @@ func (s *Server) reportPieceError(ctx context.Context, rw http.ResponseWriter, r
314314
rw.WriteHeader(http.StatusOK)
315315
return nil
316316
}
317+
318+
func (s *Server) fetchP2PNetworkInfo(ctx context.Context, rw http.ResponseWriter, req *http.Request) (err error) {
319+
return EncodeResponse(rw, http.StatusOK, &types.NetworkInfoFetchResponse{})
320+
}
321+
322+
func (s *Server) reportPeerHealth(ctx context.Context, rw http.ResponseWriter, req *http.Request) error {
323+
return EncodeResponse(rw, http.StatusOK, &types.HeartBeatResponse{})
324+
}

supernode/server/router.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func initRoute(s *Server) *mux.Router {
4848
{Method: http.MethodGet, Path: "/peer/piece/suc", HandlerFunc: s.reportPiece},
4949
{Method: http.MethodGet, Path: "/peer/service/down", HandlerFunc: s.reportServiceDown},
5050
{Method: http.MethodGet, Path: "/peer/piece/error", HandlerFunc: s.reportPieceError},
51+
{Method: http.MethodPost, Path: "/peer/network", HandlerFunc: s.fetchP2PNetworkInfo},
52+
{Method: http.MethodPost, Path: "/peer/heartbeat", HandlerFunc: s.reportPeerHealth},
5153

5254
// v1
5355
// peer

0 commit comments

Comments
 (0)