prepare

package
v0.34.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

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.

Example
package main

import (
	"context"
	"fmt"
	"log"

	"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 := append([]byte(nil), 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)

}
Output:

sess:   ccxrootdgotest.in2p3.fr:9001
stage:  "23297f000001"
cancel: ""
sess:   ccxrootdgotest.in2p3.fr:9001

Index

Examples

Constants

View Source
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.

View Source
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.

Variables

This section is empty.

Functions

This section is empty.

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

func (req Request) MarshalXrd(w *xrdenc.WBuffer) error

MarshalXrd implements xrdproto.Marshaler.

func (*Request) ReqID

func (*Request) ReqID() uint16

ReqID implements xrdproto.Request.ReqID.

func (*Request) ShouldSign

func (*Request) ShouldSign() bool

ShouldSign implements xrdproto.Request.ShouldSign.

func (*Request) UnmarshalXrd

func (req *Request) UnmarshalXrd(r *xrdenc.RBuffer) error

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

func (o Response) MarshalXrd(w *xrdenc.WBuffer) error

MarshalXrd implements xrdproto.Marshaler.

func (*Response) RespID

func (resp *Response) RespID() uint16

RespID implements xrdproto.Response.RespID.

func (*Response) UnmarshalXrd

func (o *Response) UnmarshalXrd(r *xrdenc.RBuffer) error

UnmarshalXrd implements xrdproto.Unmarshaler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL