Documentation ¶
Overview ¶
Folding@home client API wrapper for Go
Example ¶
api, err := Dial(DefaultAddr) if err != nil { panic(err) } defer api.Close() if err := api.PauseAll(); err != nil { panic(err) } if err := api.UnpauseAll(); err != nil { panic(err) }
Output:
Index ¶
- Constants
- Variables
- func ParsePyONString(b []byte) (string, error)
- func UnmarshalPyON(b []byte, dst interface{}) error
- type API
- func (a *API) AlwaysOn(slot int) error
- func (a *API) Configured() (bool, error)
- func (a *API) DoCycle() error
- func (a *API) DownloadCore(coreType string, url *url.URL) error
- func (a *API) Finish(slot int) error
- func (a *API) FinishAll() error
- func (a *API) FinishSlot(slot int) error
- func (a *API) Help() (string, error)
- func (a *API) Info() ([][]interface{}, error)
- func (a *API) InfoStruct(dst *Info) error
- func (a *API) LogUpdates(arg LogUpdatesArg) (string, error)
- func (a *API) NumSlots() (int, error)
- func (a *API) OnIdle(slot int) error
- func (a *API) OnIdleAll() error
- func (a *API) OptionsGet(dst *Options) error
- func (a *API) OptionsSet(key string, value interface{}) error
- func (a *API) PPD() (float64, error)
- func (a *API) PauseAll() error
- func (a *API) PauseSlot(slot int) error
- func (a *API) QueueInfo() ([]SlotQueueInfo, error)
- func (a *API) RequestID() error
- func (a *API) RequestWS() error
- func (a *API) Screensaver() error
- func (a *API) Shutdown() error
- func (a *API) SimulationInfo(slot int, dst *SimulationInfo) error
- func (a *API) SlotDelete(slot int) error
- func (a *API) SlotInfo() ([]SlotInfo, error)
- func (a *API) SlotOptionsGet(slot int, dst *SlotOptions) error
- func (a *API) SlotOptionsSet(slot int, key string, value interface{}) error
- func (a *API) UnpauseAll() error
- func (a *API) UnpauseSlot(slot int) error
- func (a *API) Uptime() (FAHDuration, error)
- func (a *API) WaitForUnits() error
- type Connection
- type FAHDuration
- type FAHTime
- type Info
- type LogUpdatesArg
- type Options
- type Power
- type SimulationInfo
- type SlotInfo
- type SlotOptions
- type SlotQueueInfo
- type StringBool
- type StringInt
Examples ¶
Constants ¶
const ( LogUpdatesStart = LogUpdatesArg("start") LogUpdatesRestart = LogUpdatesArg("restart") LogUpdatesStop = LogUpdatesArg("stop") )
Variables ¶
var DefaultAddr = &net.TCPAddr{Port: 36330}
DefaultAddr is the default TCP address of the FAH client.
Functions ¶
func ParsePyONString ¶
func UnmarshalPyON ¶
Types ¶
type API ¶
type API struct { *Connection // contains filtered or unexported fields }
API contains the client connection. Use Dial() to get a new instance, and api.Close() to close the connection.
func (*API) AlwaysOn ¶
AlwaysOn sets a slot to be always on. (Not sure if this does anything at all.)
func (*API) Configured ¶
Configured returns true if the client has set a user, team or passkey.
func (*API) DownloadCore ¶
DownloadCore downloads a core. NOT TESTED.
func (*API) Finish ¶
Finish pauses a slot when its current work unit is completed. Deprecated: use FinishSlot().
func (*API) FinishAll ¶
FinishAll pauses all slots one-by-one when their current work unit is completed.
func (*API) FinishSlot ¶
FinishSlot pauses a slot when its current work unit is completed.
func (*API) InfoStruct ¶
InfoStruct converts Info() data into a structure. Consider this interface to be very unstable.
func (*API) LogUpdates ¶
func (a *API) LogUpdates(arg LogUpdatesArg) (string, error)
LogUpdates enables or disables log updates. Returns current log.
func (*API) OptionsGet ¶
OptionsGet returns the FAH client options.
func (*API) OptionsSet ¶
OptionsSet sets an option. value argument is turned into a string using fmt.Sprintf().
func (*API) QueueInfo ¶
func (a *API) QueueInfo() ([]SlotQueueInfo, error)
QueueInfo returns info about the current work unit.
func (*API) Screensaver ¶
Screensaver unpauses all slots which are paused waiting for a screensaver and pause them again on disconnect.
func (*API) SimulationInfo ¶
func (a *API) SimulationInfo(slot int, dst *SimulationInfo) error
SimulationInfo returns the simulation information for a slot.
func (*API) SlotOptionsGet ¶
func (a *API) SlotOptionsGet(slot int, dst *SlotOptions) error
func (*API) SlotOptionsSet ¶
func (*API) WaitForUnits ¶
WaitForUnits blocks until all slots are paused.
type Connection ¶
type Connection struct { *net.TCPConn Addr net.TCPAddr // Reconnects to this address on disconnection. }
Connection holds the TCP connection to the FAH client. None of its methods are goroutine-safe.
func DialConnection ¶
func DialConnection(addr *net.TCPAddr) (*Connection, error)
type FAHDuration ¶
FAHDuration may be "unknowntime", which can be checked by calling duration.UnknownTime().
func ParseFAHDuration ¶
func ParseFAHDuration(s string) (FAHDuration, error)
func (FAHDuration) String ¶
func (f FAHDuration) String() string
func (FAHDuration) UnknownTime ¶
func (f FAHDuration) UnknownTime() bool
func (*FAHDuration) UnmarshalJSON ¶
func (f *FAHDuration) UnmarshalJSON(b []byte) error
type FAHTime ¶
FAHTime can be invalid, which can be checked with time.Invalid().
func ParseFAHTime ¶
func (*FAHTime) UnmarshalJSON ¶
type Info ¶
type Info struct { FAHClient struct { Version string Author string Copyright string Homepage string Date string Time string Revision string Branch string Compiler string Options string Platform string Bits string Mode string Args string Config string } CBang struct { Date string Time string Revision string Branch string Compiler string Options string Platform string Bits string Mode string } System struct { CPU string CPUID string CPUs StringInt Memory string FreeMemory string Threads string OSVersion string HasBattery string OnBattery string UTCOffset string PID string CWD string OS string OSArch string GPUs StringInt } LibFAH struct { Date string Time string Revision string Branch string Compiler string Options string Platform string Bits string Mode string } }
type LogUpdatesArg ¶
type LogUpdatesArg string
type Options ¶
type Options struct { Allow string `json:"allow"` CaptureDirectory string `json:"capture-directory"` CaptureOnError StringBool `json:"capture-on-error"` CapturePackets StringBool `json:"capture-packets"` CaptureRequests StringBool `json:"capture-requests"` CaptureResponses StringBool `json:"capture-responses"` CaptureSockets StringBool `json:"capture-sockets"` Cause string `json:"cause"` CertificateFile string `json:"certificate-file"` Checkpoint StringInt `json:"checkpoint"` Child StringBool `json:"child"` ClientSubtype string `json:"client-subtype"` ClientThreads StringInt `json:"client-threads"` ClientType string `json:"client-type"` CommandAddress string `json:"command-address"` CommandAllowNoPass string `json:"command-allow-no-pass"` Deny string `json:"deny"` CommandDenyNoPass string `json:"command-deny-no-pass"` CommandEnable StringBool `json:"command-enable"` CommandPort StringInt `json:"command-port"` ConfigRotate StringBool `json:"config-rotate"` ConfigRotateDir string `json:"config-rotate-dir"` ConfigRotateMax StringInt `json:"config-rotate-max"` ConnectionTimeout StringInt `json:"connection-timeout"` CorePriority string `json:"core-priority"` CpuSpecies string `json:"cpu-species"` CpuType string `json:"cpu-type"` CpuUsage StringInt `json:"cpu-usage"` Cpus StringInt `json:"cpus"` CrlFile string `json:"crl-file"` CudaIndex string `json:"cuda-index"` CycleRate StringInt `json:"cycle-rate"` Cycles StringInt `json:"cycles"` Daemon StringBool `json:"daemon"` DebugSockets StringBool `json:"debug-sockets"` DisableSleepWhenActive StringBool `json:"disable-sleep-when-active"` DisableViz StringBool `json:"disable-viz"` DumpAfterDeadline StringBool `json:"dump-after-deadline"` ExceptionLocations StringBool `json:"exception-locations"` ExitWhenDone StringBool `json:"exit-when-done"` ExtraCoreArgs string `json:"extra-core-args"` FoldAnon StringBool `json:"fold-anon"` Gpu StringBool `json:"gpu"` GpuIndex string `json:"gpu-index"` GpuUsage StringInt `json:"gpu-usage"` GuiEnabled StringBool `json:"gui-enabled"` HttpAddresses string `json:"http-addresses"` HttpsAddresses string `json:"https-addresses"` Idle StringBool `json:"idle"` Log string `json:"log"` LogColor StringBool `json:"log-color"` LogCrlf StringBool `json:"log-crlf"` LogDate StringBool `json:"log-date"` LogDatePeriodically StringInt `json:"log-date-periodically"` LogDomain StringBool `json:"log-domain"` LogDomainLevels string `json:"log-domain-levels"` LogHeader StringBool `json:"log-header"` LogLevel StringBool `json:"log-level"` LogNoInfoHeader StringBool `json:"log-no-info-header"` LogRedirect StringBool `json:"log-redirect"` LogRotate StringBool `json:"log-rotate"` LogRotateDir string `json:"log-rotate-dir"` LogRotateMax StringInt `json:"log-rotate-max"` LogShortLevel StringBool `json:"log-short-level"` LogSimpleDomains StringBool `json:"log-simple-domains"` LogThreadId StringBool `json:"log-thread-id"` LogThreadPrefix StringBool `json:"log-thread-prefix"` LogTime StringBool `json:"log-time"` LogToScreen StringBool `json:"log-to-screen"` LogTruncate StringBool `json:"log-truncate"` MachineId StringInt `json:"machine-id"` MaxConnectTime StringInt `json:"max-connect-time"` MaxConnections StringInt `json:"max-connections"` MaxPacketSize string `json:"max-packet-size"` MaxQueue StringInt `json:"max-queue"` MaxRequestLength StringInt `json:"max-request-length"` MaxShutdownWait StringInt `json:"max-shutdown-wait"` MaxSlotErrors StringInt `json:"max-slot-errors"` MaxUnitErrors StringInt `json:"max-unit-errors"` MaxUnits StringInt `json:"max-units"` Memory string `json:"memory"` MinConnectTime StringInt `json:"min-connect-time"` NextUnitPercentage StringInt `json:"next-unit-percentage"` Priority string `json:"priority"` NoAssembly StringBool `json:"no-assembly"` OpenWebControl StringBool `json:"open-web-control"` OpenclIndex string `json:"opencl-index"` OsSpecies string `json:"os-species"` OsType string `json:"os-type"` Passkey string `json:"passkey"` Password string `json:"password"` PauseOnBattery StringBool `json:"pause-on-battery"` PauseOnStart StringBool `json:"pause-on-start"` Paused StringBool `json:"paused"` Pid StringBool `json:"pid"` PidFile string `json:"pid-file"` Power Power `json:"power"` PrivateKeyFile string `json:"private-key-file"` ProjectKey StringInt `json:"project-key"` Proxy string `json:"proxy"` ProxyEnable StringBool `json:"proxy-enable"` ProxyPass string `json:"proxy-pass"` ProxyUser string `json:"proxy-user"` Respawn StringBool `json:"respawn"` Service StringBool `json:"service"` ServiceDescription string `json:"service-description"` ServiceRestart StringBool `json:"service-restart"` ServiceRestartDelay StringInt `json:"service-restart-delay"` SessionCookie string `json:"session-cookie"` SessionLifetime StringInt `json:"session-lifetime"` SessionTimeout StringInt `json:"session-timeout"` Smp StringBool `json:"smp"` StackTraces StringBool `json:"stack-traces"` StallDetectionEnabled StringBool `json:"stall-detection-enabled"` StallPercent StringInt `json:"stall-percent"` StallTimeout StringInt `json:"stall-timeout"` Team StringInt `json:"team"` User string `json:"user"` Verbosity StringInt `json:"verbosity"` WebAllow string `json:"web-allow"` WebDeny string `json:"web-deny"` WebEnable StringBool `json:"web-enable"` }
type SimulationInfo ¶
type SimulationInfo struct { User string `json:"user"` Team string `json:"team"` Project int `json:"project"` Run int `json:"run"` Clone int `json:"clone"` Gen int `json:"gen"` CoreType int `json:"core_type"` Core string `json:"core"` TotalIterations int `json:"total_iterations"` IterationsDone int `json:"iterations_done"` Energy int `json:"energy"` Temperature int `json:"temperature"` StartTime FAHTime `json:"start_time"` Timeout int `json:"timeout"` Deadline int `json:"deadline"` ETA int `json:"eta"` Progress float64 `json:"progress"` Slot int `json:"slot"` }
type SlotOptions ¶
type SlotOptions struct { MachineID string `json:"machine-id"` Paused StringBool `json:"paused"` }
type SlotQueueInfo ¶
type SlotQueueInfo struct { ID string `json:"id"` State string `json:"state"` Error string `json:"error"` Project int `json:"project"` Run int `json:"run"` Clone int `json:"clone"` Gen int `json:"gen"` Core string `json:"core"` Unit string `json:"unit"` PercentDone string `json:"percentdone"` ETA FAHDuration `json:"eta"` PPD StringInt `json:"ppd"` CreditEstimate StringInt `json:"creditestimate"` WaitingOn string `json:"waitingon"` NextAttempt FAHDuration `json:"nextattempt"` TimeRemaining FAHDuration `json:"timeremaining"` TotalFrames int `json:"totalframes"` FramesDone int `json:"framesdone"` Assigned FAHTime `json:"assigned"` Timeout FAHTime `json:"timeout"` Deadline FAHTime `json:"deadline"` WS string `json:"ws"` CS string `json:"cs"` Attempts int `json:"attempts"` Slot string `json:"slot"` TPF FAHDuration `json:"tpf"` BaseCredit StringInt `json:"basecredit"` }
type StringBool ¶
type StringBool bool
func (*StringBool) UnmarshalJSON ¶
func (s *StringBool) UnmarshalJSON(b []byte) error