forked from tangled.org/core
this repo has no description

knotserver/jsclient: reenable cursor and better logging

Changed files
+7 -4
knotserver
+2
knotserver/handler.go
···
}
}()
+
log.Printf("started jetstream")
+
return nil
}
+5 -4
knotserver/jsclient/jetstream.go
···
RawQuery: queryParams,
}
-
fmt.Println("URL:", u.String())
return u
}
···
var collections, dids string
if len(j.collections) > 0 {
-
collections = fmt.Sprintf("wantedCollections=%s", j.collections[0])
+
collections = fmt.Sprintf("wantedCollections=%s&cursor=%d", j.collections[0], cursor)
for _, collection := range j.collections[1:] {
collections += fmt.Sprintf("&wantedCollections=%s", collection)
}
···
func (j *JetstreamClient) connect(cursor int64) error {
queryParams := j.buildQueryParams(cursor)
u := j.buildWebsocketURL(queryParams)
+
+
log.Printf("connecting to jetstream at: %s", u.String())
dialer := websocket.Dialer{
HandshakeTimeout: 10 * time.Second,
···
return
case <-j.reconnectCh:
// Reconnect with new parameters
-
// cursor := time.Now().Add(-5 * time.Second).UnixMicro()
-
if err := j.connect(0); err != nil {
+
cursor := time.Now().Add(-5 * time.Second).UnixMicro()
+
if err := j.connect(cursor); err != nil {
log.Printf("error reconnecting to jetstream: %v", err)
return
}