docs(proxy): sharpen AX usage examples
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
1e6ba01d03
commit
e2bd10c94f
4 changed files with 10 additions and 6 deletions
|
|
@ -23,6 +23,7 @@ type Router interface {
|
|||
|
||||
// RegisterRoutes wires the monitoring endpoints onto the supplied router.
|
||||
//
|
||||
// mux := http.NewServeMux()
|
||||
// proxyapi.RegisterRoutes(mux, p)
|
||||
// // GET /1/summary, /1/workers, and /1/miners are now live.
|
||||
func RegisterRoutes(router Router, p *proxy.Proxy) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package proxy
|
|||
|
||||
// Config is the top-level proxy configuration, loaded from JSON and hot-reloaded on change.
|
||||
//
|
||||
// cfg, result := proxy.LoadConfig("config.json")
|
||||
// if !result.OK { log.Fatal(result.Error) }
|
||||
// cfg, result := proxy.LoadConfig("/etc/proxy.json")
|
||||
// if !result.OK {
|
||||
// return result.Error
|
||||
// }
|
||||
type Config struct {
|
||||
Mode string `json:"mode"` // "nicehash" or "simple"
|
||||
Bind []BindAddr `json:"bind"` // listen addresses
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ func getSplitterFactory(mode string) (func(*Config, *EventBus) Splitter, bool) {
|
|||
|
||||
// LoadConfig reads and unmarshals a JSON config file.
|
||||
//
|
||||
// cfg, result := LoadConfig("config.json")
|
||||
// cfg, result := LoadConfig("/etc/proxy.json")
|
||||
// if !result.OK {
|
||||
// return
|
||||
// return result.Error
|
||||
// }
|
||||
func LoadConfig(path string) (*Config, Result) {
|
||||
data, err := os.ReadFile(path)
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@ type MinerSnapshot struct {
|
|||
|
||||
// New creates the proxy and wires the default event handlers.
|
||||
//
|
||||
// cfg := &proxy.Config{Mode: "nicehash", Bind: []proxy.BindAddr{{Host: "0.0.0.0", Port: 3333}}, Pools: []proxy.PoolConfig{{URL: "pool.example:3333", Enabled: true}}}
|
||||
// p, result := proxy.New(cfg)
|
||||
// if !result.OK {
|
||||
// return
|
||||
// return result.Error
|
||||
// }
|
||||
func New(config *Config) (*Proxy, Result) {
|
||||
if config == nil {
|
||||
|
|
@ -315,7 +316,7 @@ func (p *Proxy) closeAllMiners() {
|
|||
|
||||
// Reload swaps the live configuration and updates dependent state.
|
||||
//
|
||||
// p.Reload(updatedCfg)
|
||||
// p.Reload(&proxy.Config{Mode: "simple", Pools: []proxy.PoolConfig{{URL: "pool.example:3333", Enabled: true}}})
|
||||
func (p *Proxy) Reload(config *Config) {
|
||||
if p == nil || config == nil {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue