Documentation ¶
Index ¶
- Constants
- Variables
- func DxAPI(ctx context.Context, client *http.Client, numRetries int, dxEnv *DXEnvironment, ...) ([]byte, error)
- func DxDescribeBulkObjects(ctx context.Context, httpClient *http.Client, dxEnv *DXEnvironment, ...) (map[string]DxDescribeDataObject, error)
- func DxHttpRequest(ctx context.Context, client *http.Client, numRetries int, requestType string, ...) (*http.Response, error)
- func DxHttpRequestData(ctx context.Context, httpClient *http.Client, requestType string, url string, ...) error
- func MinInt(x, y int) int
- func MinInt64(x, y int64) int64
- func NewHttpClient() *http.Client
- func PrintLogAndOut(a string, args ...interface{})
- type DBPart
- type DBPartRegular
- type DBPartSymlink
- type DXAuthorization
- type DXConfig
- type DXDownloadURL
- type DXEnvironment
- type DXFile
- type DXFileRegular
- type DXFileSymlink
- type DXPart
- type DXSymlink
- type DownloadStatus
- type DxDescribeDataObject
- type DxDescribeRaw
- type DxDescribeRawTop
- type DxError
- type DxErrorJson
- type DxErrorJsonInternal
- type DxSymlinkRaw
- type HttpError
- type JobInfo
- type Manifest
- type ManifestRaw
- type ManifestRawFile
- type Opts
- type Reply
- type Request
- type RequestWithScope
- type State
- func (st *State) CheckDiskSpace() error
- func (st *State) CheckFileIntegrity() bool
- func (st *State) Close()
- func (st *State) CreateManifestDB(manifest Manifest, fname string)
- func (st *State) DownloadManifestDB(fname string)
- func (st *State) DownloadProgressOneTime(timeWindowNanoSec int64) string
- func (st *State) InitDownloadStatus()
- func (st *State) PrepareFilesForDownload(m Manifest)
Constants ¶
const ( KiB = 1024 MiB = 1024 * KiB GiB = 1024 * MiB )
const ( // Extracted automatically with a shell script, so keep the format: // version = XXXX Version = "v0.6.2" )
Variables ¶
example 'dxda/v0.1.2 (linux)
Functions ¶
func DxAPI ¶ added in v0.4.0
func DxAPI( ctx context.Context, client *http.Client, numRetries int, dxEnv *DXEnvironment, api string, payload string) ([]byte, error)
DxAPI - Function to wrap a generic API call to DNAnexus
func DxDescribeBulkObjects ¶ added in v0.4.0
func DxDescribeBulkObjects( ctx context.Context, httpClient *http.Client, dxEnv *DXEnvironment, projectId string, objIds []string) (map[string]DxDescribeDataObject, error)
func DxHttpRequest ¶ added in v0.4.0
func DxHttpRequest( ctx context.Context, client *http.Client, numRetries int, requestType string, URL string, headers map[string]string, data []byte) (*http.Response, error)
Add retries around the core http-request method
func DxHttpRequestData ¶ added in v0.4.0
func DxHttpRequestData( ctx context.Context, httpClient *http.Client, requestType string, url string, headers map[string]string, data []byte, dataLen int, memoryBuf []byte) error
Read data from a remote URL.
Add retries around the core http-request method, especially in the case of short reads.
func MinInt ¶ added in v0.4.0
Min ... https://mrekucci.blogspot.com/2015/07/dont-abuse-mathmax-mathmin.html
func NewHttpClient ¶ added in v0.4.0
These clients are intended for reuse in the same host. Throwing them away will gradually leak file descriptors.
func PrintLogAndOut ¶ added in v0.1.5
func PrintLogAndOut(a string, args ...interface{})
print to the log and to stdout
Types ¶
type DBPart ¶
type DBPart interface {
// contains filtered or unexported methods
}
a part to be downloaded. Can be: 1) part of a regular file 2) part of symbolic link (a web address)
type DBPartRegular ¶ added in v0.4.0
type DBPartRegular struct { FileId string Project string FileName string Folder string PartId int Offset int64 Size int MD5 string BytesFetched int DownloadDoneTime int64 // The time when it completed downloading }
Part of a dnanexus file
type DBPartSymlink ¶ added in v0.4.0
type DBPartSymlink struct { FileId string Project string FileName string Folder string PartId int Offset int64 Size int BytesFetched int DownloadDoneTime int64 // The time when it completed downloading Url string }
symlink parts do not have checksum. There is only a global MD5 checksum on the entire file. There is also no need to get a pre-auth URL for the file
type DXAuthorization ¶
type DXAuthorization struct { AuthToken string `json:"auth_token"` AuthTokenType string `json:"auth_token_type"` }
DXAuthorization - Basic variables regarding DNAnexus authorization
type DXConfig ¶
type DXConfig struct { DXSECURITYCONTEXT string `json:"DX_SECURITY_CONTEXT"` DXAPISERVERHOST string `json:"DX_APISERVER_HOST"` DXPROJECTCONTEXTNAME string `json:"DX_PROJECT_CONTEXT_NAME"` DXPROJECTCONTEXTID string `json:"DX_PROJECT_CONTEXT_ID"` DXAPISERVERPORT string `json:"DX_APISERVER_PORT"` DXUSERNAME string `json:"DX_USERNAME"` DXAPISERVERPROTOCOL string `json:"DX_APISERVER_PROTOCOL"` DXCLIWD string `json:"DX_CLI_WD"` }
DXConfig - Basic variables regarding DNAnexus environment config
type DXDownloadURL ¶
DXDownloadURL ...
type DXEnvironment ¶ added in v0.2.2
type DXEnvironment struct { ApiServerHost string `json:"apiServerHost"` ApiServerPort int `json:"apiServerPort"` ApiServerProtocol string `json:"apiServerProtocol"` Token string `json:"token"` DxJobId string `json:"dxJobId"` }
A subset of the configuration parameters that the dx-toolkit uses.
func GetDxEnvironment ¶ added in v0.2.2
func GetDxEnvironment() (DXEnvironment, string, error)
Construct the environment structure. Return an additional string describing the source of the security token.
The DXEnvironment has its fields set from the following sources, in order (with later items overriding earlier items):
1. Hardcoded defaults 2. Environment variables of the format DX_* 3. Configuration file ~/.dnanexus_config/environment.json
If no token can be obtained from these methods, an empty environment is returned. If the token was received from the 'DX_API_TOKEN' environment variable, the second variable in the pair will be the string 'environment'. If it is obtained from a DNAnexus configuration file, the second variable in the pair will be '.dnanexus_config/environment.json'.
type DXFile ¶
type DXFile interface {
// contains filtered or unexported methods
}
one interface representing both symbolic links and data files
type DXFileRegular ¶ added in v0.4.0
type DXFileRegular struct { Folder string Id string ProjId string Name string Size int64 Parts []DXPart }
Data file on dnanexus
type DXFileSymlink ¶ added in v0.4.0
type DXPart ¶
type DXPart struct { // we add the part-id in a post-processing step Id int // these fields are in the input JSON MD5 string `json:"md5"` Size int `json:"size"` }
description of part of a file
type DXSymlink ¶ added in v0.4.0
a full URL for symbolic links, with a corresponding MD5 checksum for the entire file. Drive and MD5 of symlnk
type DownloadStatus ¶
type DownloadStatus struct { NumParts int64 NumBytes int64 NumPartsComplete int64 NumBytesComplete int64 // periodicity of progress report ProgressInterval time.Duration // Size of window in nanoseconds where to look for // completed downloads MaxWindowSize int64 }
DownloadStatus ...
type DxDescribeDataObject ¶ added in v0.4.0
type DxDescribeDataObject struct { Id string ProjId string Name string State string ArchivalState string Folder string Size int64 Parts map[string]DXPart // a list of parts for a DNAx file Symlink *DXSymlink }
Description of a DNAx data object
type DxDescribeRaw ¶ added in v0.4.0
type DxDescribeRaw struct { Id string `json:"id"` ProjId string `json:"project"` Name string `json:"name"` State string `json:"state"` ArchivalState string `json:"archivalState"` Size int64 `json:"size"` Parts map[string]DXPart `json:"parts"` Symlink *DxSymlinkRaw `json:"symlinkPath,omitempty"` MD5 *string `json:"md5,omitempty"` Drive *string `json:"drive,omitempty"` }
type DxDescribeRawTop ¶ added in v0.4.0
type DxDescribeRawTop struct {
Describe DxDescribeRaw `json:"describe"`
}
type DxErrorJson ¶ added in v0.4.0
type DxErrorJson struct {
E DxErrorJsonInternal `json:"error"`
}
type DxErrorJsonInternal ¶ added in v0.4.0
type DxSymlinkRaw ¶ added in v0.4.0
type DxSymlinkRaw struct {
Url string `json:"object"`
}
type Manifest ¶
type Manifest struct {
Files []DXFile
}
Manifest.
- a map from file-id to a description of a regular file
- a map from file-id to a description of a symbolic link
func ReadManifest ¶
func ReadManifest(fname string, dxEnv *DXEnvironment) (*Manifest, error)
read the manifest from a file into a memory structure
type ManifestRaw ¶ added in v0.4.0
type ManifestRaw map[string][]ManifestRawFile
Raw manifest. A list provided by the user of projects and files within them that need to be downloaded.
The representation is a mapping from project-id to a list of files
type ManifestRawFile ¶ added in v0.4.0
type ManifestRawFile struct { Folder string `json:"folder"` Id string `json:"id"` Name string `json:"name"` Parts *map[string]DXPart `json:"parts,omitempty"` }
File description in the manifest. Additional details will be gathered with an API call.
type Opts ¶
type Opts struct { NumThreads int // number of workers to process downloads Verbose bool // verbose logging GcInfo bool // Garbage collection statistics }
Configuration options for the download agent
type Reply ¶ added in v0.4.0
type Reply struct {
Results []DxDescribeRawTop `json:"results"`
}
type RequestWithScope ¶ added in v0.5.4
type State ¶ added in v0.4.0
type State struct {
// contains filtered or unexported fields
}
func NewDxDa ¶ added in v0.4.0
func NewDxDa(dxEnv DXEnvironment, fname string, optsRaw Opts) *State
Initialize the state
func (*State) CheckDiskSpace ¶ added in v0.4.0
CheckDiskSpace ... Check that we have enough disk space for all downloaded files
func (*State) CheckFileIntegrity ¶ added in v0.4.0
check the on-disk integrity of all files return false if there is an integrity problem.
func (*State) CreateManifestDB ¶ added in v0.4.0
Read the manifest file, and build a database with an empty state for each part in each file.
func (*State) DownloadManifestDB ¶ added in v0.4.0
Download all the files that are mentioned in the manifest.
func (*State) DownloadProgressOneTime ¶ added in v0.4.0
DownloadProgressOneTime ... Report on progress so far
func (*State) InitDownloadStatus ¶ added in v0.4.0
func (st *State) InitDownloadStatus()
InitDownloadStatus ...
func (*State) PrepareFilesForDownload ¶ added in v0.5.5
create an empty file for each download filepath.
TODO: Optimize this for only files that need to be downloaded