This repository has been archived by the owner on Feb 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
redefine the scheduler and update other interfaces
Signed-off-by: allen.wq <[email protected]>
- Loading branch information
1 parent
c9332ef
commit e5191eb
Showing
10 changed files
with
174 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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 distributiondata | ||
|
||
import ( | ||
"context" | ||
"io" | ||
) | ||
|
||
type DataEncoder interface { | ||
// Encode data. | ||
Encode(io.Reader) (io.Reader, error) | ||
|
||
// Decode data. | ||
Decode(io.Reader) (io.Reader, error) | ||
} | ||
|
||
// DistributionData defines the protocol of distribute data which is exchanged in peers. | ||
type DistributionData interface { | ||
// Size gets the size of data. | ||
Size() int64 | ||
|
||
// Metadata gets the metadata. | ||
Metadata() interface{} | ||
|
||
// Content gets the content of data. | ||
Content(ctx context.Context) (io.Reader, error) | ||
} | ||
|
||
// EOFDistributionData represents the eof of file. | ||
type EOFDistributionData struct{} | ||
|
||
func (eof *EOFDistributionData) Size() int64 { | ||
return 0 | ||
} | ||
|
||
func (eof *EOFDistributionData) Metadata() interface{} { | ||
return nil | ||
} | ||
|
||
func (eof *EOFDistributionData) Content(ctx context.Context) (io.Reader, error) { | ||
return nil, io.EOF | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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 url | ||
|
||
import ( | ||
"context" | ||
"io" | ||
) | ||
|
||
// ProtocolClient defines the way how to get data from remote resource. | ||
// An instance should bind a resource. | ||
// Developers can implement their own ProtocolClient which could support different protocol. | ||
type ProtocolClient interface { | ||
// Read gets range data from the binding resource. | ||
Read(ctx context.Context, off int64, size int64) (io.ReadCloser, error) | ||
|
||
// Length gets the length of binding resource. | ||
Length(ctx context.Context) (int64, error) | ||
|
||
// Metadata gets the metadata of binding resource. | ||
Metadata(ctx context.Context) (interface{}, error) | ||
|
||
// Expire gets if the binding resource is expired. | ||
Expire(ctx context.Context) (bool, interface{}, error) | ||
|
||
// Call calls the user defined method. | ||
Call(ctx context.Context, method string, request interface{}) (response interface{}, err error) | ||
} | ||
|
||
// ProtocolClientNewInstanceInterface defines how to create an instance of ProtocolClient. | ||
type ProtocolClientNewInstanceInterface interface { | ||
// NewProtocolClient creates an instance of ProtocolClient. | ||
NewProtocolClient(url string, header map[string]string, opts interface{}) (ProtocolClient, error) | ||
} | ||
|
||
// ClientRegister defines how to register pair <protocol, ProtocolClientNewInstanceInterface>. | ||
type ClientRegister interface { | ||
// RegisterProtocol registers pair <protocol, ProtocolClientNewInstanceInterface>. | ||
RegisterProtocol(protocol string, inf ProtocolClientNewInstanceInterface) | ||
|
||
// GetProtocolClientNewInstanceInterface gets the ProtocolClientNewInstanceInterface by protocol. | ||
GetProtocolClientNewInstanceInterface(protocol string) (ProtocolClientNewInstanceInterface, error) | ||
} |