package prepare
import "go-hep.org/x/hep/xrootd/xrdproto/prepare"
Package prepare contains the types related to the prepare request.
See xrootd protocol specification (http://xrootd.org/doc/dev45/XRdv310.pdf, p. 69) for more details.
Code:play
Output:Example¶
package main
import (
"context"
"fmt"
"log"
"slices"
"go-hep.org/x/hep/xrootd"
"go-hep.org/x/hep/xrootd/xrdproto/prepare"
)
func main() {
bkg := context.Background()
cl, err := xrootd.NewClient(bkg, "ccxrootdgotest.in2p3.fr:9001", "gopher")
if err != nil {
log.Fatalf("could not create client: %v", err)
}
defer cl.Close()
var (
resp prepare.Response
req = prepare.Request{
Options: prepare.Stage | prepare.Notify,
Paths: []string{"/tmp/dir1/file1.txt"},
}
)
// staging request
id, err := cl.Send(bkg, &resp, &req)
if err != nil {
log.Fatalf("stage request error: %v", err)
}
fmt.Printf("sess: %s\n", id)
fmt.Printf("stage: %q\n", resp.Data[:12]) // Locator ID
// cancel staging request
locid := slices.Clone(resp.Data)
req = prepare.Request{
Options: prepare.Cancel,
Paths: []string{string(locid)},
}
id, err = cl.Send(bkg, &resp, &req)
if err != nil {
log.Fatalf("cancel request error: %v", err)
}
fmt.Printf("cancel: %q\n", resp.Data)
fmt.Printf("sess: %s\n", id)
}
sess: ccxrootdgotest.in2p3.fr:9001
stage: "23297f000001"
cancel: ""
sess: ccxrootdgotest.in2p3.fr:9001
Index ¶
- Constants
- type Request
- func (req Request) MarshalXrd(w *xrdenc.WBuffer) error
- func (*Request) ReqID() uint16
- func (*Request) ShouldSign() bool
- func (req *Request) UnmarshalXrd(r *xrdenc.RBuffer) error
- type Response
Examples ¶
Constants ¶
const ( Cancel = 1 // Cancel will cancel a prepare request. Notify = 2 // Notify will send a message when the file has been processed. NoErrors = 4 // NoErrors will not send a notification for preparation errors. Stage = 8 // Stage will stage the file to disk if it is not online. Write = 16 // Write will prepare the file with write access. Colocate = 32 // Colocate will co-locate the staged files, if at all possible. Refresh = 64 // Refresh will refresh the file access time even when location is known. )
Prepare request options.
const RequestID uint16 = 3021
RequestID is the id of the request, it is sent as part of message. See xrootd protocol specification for details: http://xrootd.org/doc/dev45/XRdv310.pdf, 2.3 Client Request Format.
Types ¶
type Request ¶
type Request struct { Options byte // Options is a set of flags that apply to each path. Priority byte // Priority the request will have. 0: lowest priority, 3: highest. Port uint16 // UDP port number to which a message is to be sent. Paths []string // contains filtered or unexported fields }
Request holds the prepare request parameters.
func (Request) MarshalXrd ¶
MarshalXrd implements xrdproto.Marshaler.
func (*Request) ReqID ¶
ReqID implements xrdproto.Request.ReqID.
func (*Request) ShouldSign ¶
ShouldSign implements xrdproto.Request.ShouldSign.
func (*Request) UnmarshalXrd ¶
UnmarshalXrd implements xrdproto.Unmarshaler.
type Response ¶
type Response struct { Data []byte }
Response is the response issued by the server to a prepare request.
func (Response) MarshalXrd ¶
MarshalXrd implements xrdproto.Marshaler.
func (*Response) RespID ¶
RespID implements xrdproto.Response.RespID.
func (*Response) UnmarshalXrd ¶
UnmarshalXrd implements xrdproto.Unmarshaler.
Source Files ¶
prepare.go
- Version
- v0.37.1 (latest)
- Published
- Jun 3, 2025
- Platform
- linux/amd64
- Imports
- 2 packages
- Last checked
- 11 hours ago –
Tools for package owners.