enhance spider with rate limit handling, follow list updates, and improved reconnect logic; bump version to v0.29.0
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled

also reduces CPU load for spider, and minor CORS fixes
This commit is contained in:
2025-11-14 21:15:24 +00:00
parent 24eef5b5a8
commit bf8d912063
10 changed files with 266 additions and 51 deletions

View File

@@ -111,6 +111,7 @@ type RelayOption interface {
var (
_ RelayOption = (WithCustomHandler)(nil)
_ RelayOption = (WithRequestHeader)(nil)
_ RelayOption = (WithNoticeHandler)(nil)
)
// WithCustomHandler must be a function that handles any relay message that couldn't be
@@ -128,6 +129,18 @@ func (ch WithRequestHeader) ApplyRelayOption(r *Client) {
r.requestHeader = http.Header(ch)
}
// WithNoticeHandler must be a function that handles NOTICE messages from the relay.
type WithNoticeHandler func(notice []byte)
func (nh WithNoticeHandler) ApplyRelayOption(r *Client) {
r.notices = make(chan []byte, 8)
go func() {
for notice := range r.notices {
nh(notice)
}
}()
}
// String just returns the relay URL.
func (r *Client) String() string {
return r.URL