Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f53c9a7e
Commit
f53c9a7e
authored
Apr 12, 2017
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build external watch event so simple encoders can encode
parent
67f2a7cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
watch.go
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/watch.go
+23
-3
No files found.
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/watch.go
View file @
f53c9a7e
...
@@ -205,9 +205,18 @@ func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
...
@@ -205,9 +205,18 @@ func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
unknown
.
Raw
=
buf
.
Bytes
()
unknown
.
Raw
=
buf
.
Bytes
()
event
.
Object
=
&
unknown
event
.
Object
=
&
unknown
// the internal event will be versioned by the encoder
// create the external type directly and encode it. Clients will only recognize the serialization we provide.
// The internal event is being reused, not reallocated so its just a few extra assignments to do it this way
// and we get the benefit of using conversion functions which already have to stay in sync
outEvent
:=
&
metav1
.
WatchEvent
{}
*
internalEvent
=
metav1
.
InternalEvent
(
event
)
*
internalEvent
=
metav1
.
InternalEvent
(
event
)
if
err
:=
e
.
Encode
(
internalEvent
);
err
!=
nil
{
err
:=
metav1
.
Convert_versioned_InternalEvent_to_versioned_Event
(
internalEvent
,
outEvent
,
nil
)
if
err
!=
nil
{
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"unable to convert watch object: %v"
,
err
))
// client disconnect.
return
}
if
err
:=
e
.
Encode
(
outEvent
);
err
!=
nil
{
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"unable to encode watch object: %v (%#v)"
,
err
,
e
))
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"unable to encode watch object: %v (%#v)"
,
err
,
e
))
// client disconnect.
// client disconnect.
return
return
...
@@ -264,8 +273,19 @@ func (s *WatchServer) HandleWS(ws *websocket.Conn) {
...
@@ -264,8 +273,19 @@ func (s *WatchServer) HandleWS(ws *websocket.Conn) {
event
.
Object
=
&
unknown
event
.
Object
=
&
unknown
// the internal event will be versioned by the encoder
// the internal event will be versioned by the encoder
// create the external type directly and encode it. Clients will only recognize the serialization we provide.
// The internal event is being reused, not reallocated so its just a few extra assignments to do it this way
// and we get the benefit of using conversion functions which already have to stay in sync
outEvent
:=
&
metav1
.
WatchEvent
{}
*
internalEvent
=
metav1
.
InternalEvent
(
event
)
*
internalEvent
=
metav1
.
InternalEvent
(
event
)
if
err
:=
s
.
Encoder
.
Encode
(
internalEvent
,
streamBuf
);
err
!=
nil
{
err
:=
metav1
.
Convert_versioned_InternalEvent_to_versioned_Event
(
internalEvent
,
outEvent
,
nil
)
if
err
!=
nil
{
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"unable to convert watch object: %v"
,
err
))
// client disconnect.
s
.
Watching
.
Stop
()
return
}
if
err
:=
s
.
Encoder
.
Encode
(
outEvent
,
streamBuf
);
err
!=
nil
{
// encoding error
// encoding error
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"unable to encode event: %v"
,
err
))
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"unable to encode event: %v"
,
err
))
s
.
Watching
.
Stop
()
s
.
Watching
.
Stop
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment