htcondor

package module
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: BSD-3-Clause Imports: 13 Imported by: 4

README

htcondor-go

Packages for interacting with HTCondor from Go

Test in Docker GoDoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CommandDuration is a prometheus histogram metric that records the
	// duration to run each command. It is up to the client to register this
	// metric with the prometheus client, e.g.
	//
	//    func init() {
	//        prometheus.MustRegister(htcondor.CommandDuration)
	//    }
	CommandDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name: "htcondor_client_command_duration_seconds",
			Help: "Histogram of command runtimes.",
		},
		[]string{"command"},
	)
)

Functions

This section is empty.

Types

type Command

type Command struct {
	// Command is HTCondor command to run.
	Command string
	// Pool is HTCondor pool (collector) to query.
	Pool string
	// Name is the -name argument.
	Name string
	// Limit is the -limit argument.
	Limit int
	// Constraint sets the -constraint argument.
	Constraint string
	// Attributes is a list of specific attributes to return.
	// If Attributes is empty, all attributes are returned.
	Attributes []string
	// Args is a list of any extra arguments to pass.
	Args []string
	// contains filtered or unexported fields
}

Command represents an HTCondor command-line tool, e.g. condor_q.

It implements a builder pattern, so you can call e.g.

NewCommand("condor_q").WithPool("mypool:9618").WithName("myschedd").WithConstraint("Owner == \"Me\"")

You can also build it directly, e.g.

c := Command{
   Command: "condor_q",
   Pool: "mypool:9618",
   Name: "myschedd",
   Constraint: "Owner == \"Me\"",
}

func NewCommand

func NewCommand(command string) *Command

NewCommand creates a new HTCondor command.

func (*Command) Cmd

func (c *Command) Cmd() *exec.Cmd

Cmd generates an exec.Cmd you can use to run the command manually. Use Run() to run the command and get back ClassAds.

func (*Command) CmdContext

func (c *Command) CmdContext(ctx context.Context) *exec.Cmd

CmdContext generates an exec.Cmd with context you can use to run the command manually. Use Run() to run the command and get back ClassAds.

func (*Command) Copy

func (c *Command) Copy() *Command

Copy returns a new copy of the command, useful for adding further arguments without changing the base command. The commands share the cache.

func (*Command) MakeArgs

func (c *Command) MakeArgs() []string

MakeArgs builds the complete argument list to be passed to the command.

func (*Command) Run

func (c *Command) Run() ([]classad.ClassAd, error)

Run runs the command and returns the ClassAds. Use Cmd() if you need more control over the handling of the output.

func (*Command) RunWithContext

func (c *Command) RunWithContext(ctx context.Context) ([]classad.ClassAd, error)

RunWithContext runs the command with the given context and returns the ClassAds. Use Cmd() if you need more control over the handling of the output.

func (*Command) Stream

func (c *Command) Stream(ch chan classad.ClassAd, errors chan error)

Stream runs the command and sends the ClassAds on a channel. Errors are returned on a separate channel. Both will be closed when the command is done.

N.B. if using Stream with a cache you'll lose much of performance and memory advantages of streaming, since the entire HTCondor response must be read, whether from HTCondor or from the cache, before the classads can be sent.

func (*Command) StreamWithContext

func (c *Command) StreamWithContext(ctx context.Context, ch chan classad.ClassAd, errors chan error)

StreamWithContext runs the command with the given context and sends the ClassAds on a channel. Errors are returned on a separate channel. Both will be closed when the command is done.

N.B. if using Stream with a cache you'll lose much of performance and memory advantages of streaming, since the entire HTCondor response must be read, whether from HTCondor or from the cache, before the classads can be sent.

func (*Command) WithArg

func (c *Command) WithArg(arg string) *Command

WithArg adds an extra argument to pass. Can be called multiple times.

func (*Command) WithAttribute

func (c *Command) WithAttribute(attribute string) *Command

WithAttribute sets a specific attribute to return, rather than the entire ClassAd. Can be called multiple times.

func (*Command) WithCache

func (c *Command) WithCache(pool *groupcache.HTTPPool, group string, cacheBytes int64, cacheLifetime time.Duration) *Command

WithCache initializes a groupcache group for the client. Set cacheLifetime to 0 to *never* expire cached queries (unless they are LRU evicted).

func (*Command) WithConstraint

func (c *Command) WithConstraint(constraint string) *Command

WithConstraint set the -constraint argument for the command.

func (*Command) WithLimit

func (c *Command) WithLimit(limit int) *Command

WithLimit sets the -limit argument for the command.

func (*Command) WithName

func (c *Command) WithName(name string) *Command

WithName sets the -name argument for the command.

func (*Command) WithPool

func (c *Command) WithPool(pool string) *Command

WithPool sets the -pool argument for the command.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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