Documentation
¶
Index ¶
- Variables
- type Command
- func (c *Command) Cmd() *exec.Cmd
- func (c *Command) CmdContext(ctx context.Context) *exec.Cmd
- func (c *Command) Copy() *Command
- func (c *Command) MakeArgs() []string
- func (c *Command) Run() ([]classad.ClassAd, error)
- func (c *Command) RunWithContext(ctx context.Context) ([]classad.ClassAd, error)
- func (c *Command) Stream(ch chan classad.ClassAd, errors chan error)
- func (c *Command) StreamWithContext(ctx context.Context, ch chan classad.ClassAd, errors chan error)
- func (c *Command) WithArg(arg string) *Command
- func (c *Command) WithAttribute(attribute string) *Command
- func (c *Command) WithCache(pool *groupcache.HTTPPool, group string, cacheBytes int64, ...) *Command
- func (c *Command) WithConstraint(constraint string) *Command
- func (c *Command) WithLimit(limit int) *Command
- func (c *Command) WithName(name string) *Command
- func (c *Command) WithPool(pool string) *Command
Constants ¶
This section is empty.
Variables ¶
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 ¶
NewCommand creates a new HTCondor command.
func (*Command) 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 ¶
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 ¶
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) Run ¶
Run runs the command and returns the ClassAds. Use Cmd() if you need more control over the handling of the output.
func (*Command) RunWithContext ¶
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 ¶
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) WithAttribute ¶
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 ¶
WithConstraint set the -constraint argument for the command.