mirror of
https://github.com/rancher/norman.git
synced 2025-08-30 21:52:02 +00:00
Fix subscription dropping after 30 seconds
This commit is contained in:
parent
e4d341fa65
commit
b33c29d49e
@ -3,7 +3,7 @@ package subscribe
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
@ -124,8 +124,8 @@ func handler(apiContext *types.APIContext) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group is already done at this point because of goroutine above, this is just to send the error if needed
|
// no point in ever returning null because the connection is hijacked and we can't write it
|
||||||
return readerGroup.Wait()
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeData(c *websocket.Conn, header string, buf []byte) error {
|
func writeData(c *websocket.Conn, header string, buf []byte) error {
|
||||||
@ -158,7 +158,7 @@ func streamStore(ctx context.Context, eg *errgroup.Group, apiContext *types.APIC
|
|||||||
result <- e
|
result <- e
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return errors.New("disconnect")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,9 +142,12 @@ func (p *Store) List(apiContext *types.APIContext, schema *types.Schema, opt *ty
|
|||||||
func (p *Store) Watch(apiContext *types.APIContext, schema *types.Schema, opt *types.QueryOptions) (chan map[string]interface{}, error) {
|
func (p *Store) Watch(apiContext *types.APIContext, schema *types.Schema, opt *types.QueryOptions) (chan map[string]interface{}, error) {
|
||||||
namespace := getNamespace(apiContext, opt)
|
namespace := getNamespace(apiContext, opt)
|
||||||
|
|
||||||
|
timeout := int64(60 * 60)
|
||||||
req := p.common(namespace, p.k8sClient.Get())
|
req := p.common(namespace, p.k8sClient.Get())
|
||||||
req.VersionedParams(&metav1.ListOptions{
|
req.VersionedParams(&metav1.ListOptions{
|
||||||
Watch: true,
|
Watch: true,
|
||||||
|
TimeoutSeconds: &timeout,
|
||||||
|
ResourceVersion: "0",
|
||||||
}, dynamic.VersionedParameterEncoderWithV1Fallback)
|
}, dynamic.VersionedParameterEncoderWithV1Fallback)
|
||||||
|
|
||||||
body, err := req.Stream()
|
body, err := req.Stream()
|
||||||
|
@ -11,6 +11,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Chan(c <-chan map[string]interface{}, f func(map[string]interface{}) map[string]interface{}) chan map[string]interface{} {
|
func Chan(c <-chan map[string]interface{}, f func(map[string]interface{}) map[string]interface{}) chan map[string]interface{} {
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
result := make(chan map[string]interface{})
|
result := make(chan map[string]interface{})
|
||||||
go func() {
|
go func() {
|
||||||
for data := range c {
|
for data := range c {
|
||||||
|
Loading…
Reference in New Issue
Block a user