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

Commit

Permalink
Merge pull request #1355 from antsystem/feat/update-dfget-interface-t…
Browse files Browse the repository at this point in the history
…ype-define

move some types to basic package
  • Loading branch information
lowzj committed May 21, 2020
2 parents 4350001 + cefdca4 commit 88cb9fa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
30 changes: 30 additions & 0 deletions dfget/corev2/basic/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright The Dragonfly Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package basic

import (
"github.com/dragonflyoss/Dragonfly/apis/types"
)

// SchedulerResult defines the result of schedule of range data.
type SchedulePieceDataResult struct {
Off int64
Size int64

// PeerInfos represents the schedule peers which to get the range data.
PeerInfos []*types.PeerInfo
}
22 changes: 1 addition & 21 deletions dfget/corev2/datascheduler/data_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,13 @@ import (
"context"

"github.com/dragonflyoss/Dragonfly/dfget/corev2/basic"

strfmt "github.com/go-openapi/strfmt"
)

// PeerInfo represents the target address which is provided the download data.
type PeerInfo struct {
IP strfmt.IPv4
Port int32
Path string
// ID represents the client ID of peer.
ID string
}

// SchedulerResult defines the result of schedule of range data.
type SchedulePieceDataResult struct {
Off int64
Size int64

// PeerInfos represents the schedule peers which to get the range data.
PeerInfos []*PeerInfo
}

// SchedulerResult defines the schedule result of request range.
// For some implementation, developer could do more than one schedule for the same request range.
type SchedulerResult interface {
// Result get the schedule result for range data which may not include all data of request range.
Result() []*SchedulePieceDataResult
Result() []*basic.SchedulePieceDataResult

// State gets the temporary states of this schedule which binds to range request.
State() ScheduleState
Expand Down

0 comments on commit 88cb9fa

Please sign in to comment.