enhance spider with rate limit handling, follow list updates, and improved reconnect logic; bump version to v0.29.0
also reduces CPU load for spider, and minor CORS fixes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user