From 09a1ab585ac62d18eb2308b07a4fa71449365354 Mon Sep 17 00:00:00 2001 From: "allen.wq" Date: Thu, 21 May 2020 10:39:09 +0800 Subject: [PATCH] move some types to basic package Signed-off-by: allen.wq --- dfget/corev2/basic/types.go | 39 ++++++++++++++++++++ dfget/corev2/datascheduler/data_scheduler.go | 22 +---------- 2 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 dfget/corev2/basic/types.go diff --git a/dfget/corev2/basic/types.go b/dfget/corev2/basic/types.go new file mode 100644 index 000000000..032c1901a --- /dev/null +++ b/dfget/corev2/basic/types.go @@ -0,0 +1,39 @@ +/* + * 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 ( + 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 +} diff --git a/dfget/corev2/datascheduler/data_scheduler.go b/dfget/corev2/datascheduler/data_scheduler.go index 951289c53..7fa79a22d 100644 --- a/dfget/corev2/datascheduler/data_scheduler.go +++ b/dfget/corev2/datascheduler/data_scheduler.go @@ -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