Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
define new apis
Browse files Browse the repository at this point in the history
+ /peer/network
+ /peer/heartbeat

Signed-off-by: henry.hj <[email protected]>
  • Loading branch information
henry.hj committed May 6, 2020
1 parent 4eda7c3 commit a2670f4
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
23 changes: 22 additions & 1 deletion apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ paths:
200:
description: "no error"
schema:
$ref: "#/definitions/ResultInfo"
$ref: "#/definitions/HeartBeatResponse"
500:
$ref: "#/responses/500ErrorResponse"

Expand Down Expand Up @@ -1511,6 +1511,27 @@ definitions:
This dfget is treated a client and carries a client ID.
Thus, multiple dfget processes on the same peer have different CIDs.
HeartBeatResponse:
type: "object"
description: ""
properties:
version:
type: "string"
description: |
The version of supernode. If supernode restarts, version should be different, so dfdaemon could know
the restart of supernode.
needRegister:
type: "boolean"
description: |
If peer do not register in supernode, set needRegister to be true, else set to be false.
seedTaskIDs:
type: "array"
description: |
The array of seed taskID which now are selected as seed for the peer. If peer have other seed file which
is not included in the array, these seed file should be weed out.
items:
type: "string"

ErrorResponse:
type: "object"
description: |
Expand Down
54 changes: 54 additions & 0 deletions apis/types/heart_beat_response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions supernode/server/0.3_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,11 @@ func (s *Server) reportPieceError(ctx context.Context, rw http.ResponseWriter, r
rw.WriteHeader(http.StatusOK)
return nil
}

func (s *Server) fetchP2PNetworkInfo(ctx context.Context, rw http.ResponseWriter, req *http.Request) (err error) {
return EncodeResponse(rw, http.StatusOK, &types.NetworkInfoFetchResponse{})
}

func (s *Server) reportPeerHealth(ctx context.Context, rw http.ResponseWriter, req *http.Request) error {
return EncodeResponse(rw, http.StatusOK, &types.HeartBeatResponse{})
}
2 changes: 2 additions & 0 deletions supernode/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func initRoute(s *Server) *mux.Router {
{Method: http.MethodGet, Path: "/peer/piece/suc", HandlerFunc: s.reportPiece},
{Method: http.MethodGet, Path: "/peer/service/down", HandlerFunc: s.reportServiceDown},
{Method: http.MethodGet, Path: "/peer/piece/error", HandlerFunc: s.reportPieceError},
{Method: http.MethodPost, Path: "/peer/network", HandlerFunc: s.fetchP2PNetworkInfo},
{Method: http.MethodPost, Path: "/peer/heartbeat", HandlerFunc: s.reportPeerHealth},

// v1
// peer
Expand Down

0 comments on commit a2670f4

Please sign in to comment.