@@ -41,15 +41,11 @@ func main() {
41
41
log .Init (ServiceName , Version , true , false )
42
42
startTime := time .Now ()
43
43
44
- log .Info ("wait until content available" )
45
-
46
- // wait until content ready
47
- contentStatus , wsInfo , err := resolveWorkspaceInfo (context .Background ())
48
- if err != nil || wsInfo == nil || contentStatus == nil || ! contentStatus .Available {
49
- log .WithError (err ).WithField ("wsInfo" , wsInfo ).WithField ("cstate" , contentStatus ).Error ("resolve workspace info failed" )
44
+ wsInfo , err := resolveWorkspaceInfo (context .Background ())
45
+ if err != nil || wsInfo == nil {
46
+ log .WithError (err ).WithField ("wsInfo" , wsInfo ).Error ("resolve workspace info failed" )
50
47
return
51
48
}
52
- log .WithField ("cost" , time .Now ().Local ().Sub (startTime ).Milliseconds ()).Info ("content available" )
53
49
54
50
// code server args install extension with id
55
51
args := []string {}
@@ -117,8 +113,8 @@ func main() {
117
113
}
118
114
}
119
115
120
- func resolveWorkspaceInfo (ctx context.Context ) (* supervisor.ContentStatusResponse , * supervisor. WorkspaceInfoResponse , error ) {
121
- resolve := func (ctx context.Context ) (contentStatus * supervisor. ContentStatusResponse , wsInfo * supervisor.WorkspaceInfoResponse , err error ) {
116
+ func resolveWorkspaceInfo (ctx context.Context ) (* supervisor.WorkspaceInfoResponse , error ) {
117
+ resolve := func (ctx context.Context ) (wsInfo * supervisor.WorkspaceInfoResponse , err error ) {
122
118
supervisorAddr := os .Getenv ("SUPERVISOR_ADDR" )
123
119
if supervisorAddr == "" {
124
120
supervisorAddr = "localhost:22999"
@@ -133,22 +129,18 @@ func resolveWorkspaceInfo(ctx context.Context) (*supervisor.ContentStatusRespons
133
129
err = errors .New ("get workspace info failed: " + err .Error ())
134
130
return
135
131
}
136
- contentStatus , err = supervisor .NewStatusServiceClient (supervisorConn ).ContentStatus (ctx , & supervisor.ContentStatusRequest {Wait : true })
137
- if err != nil {
138
- err = errors .New ("get content available failed: " + err .Error ())
139
- }
140
132
return
141
133
}
142
134
// try resolve workspace info 10 times
143
135
for attempt := 0 ; attempt < 10 ; attempt ++ {
144
- if contentStatus , wsInfo , err := resolve (ctx ); err != nil {
136
+ if wsInfo , err := resolve (ctx ); err != nil {
145
137
log .WithError (err ).Error ("resolve workspace info failed" )
146
138
time .Sleep (1 * time .Second )
147
139
} else {
148
- return contentStatus , wsInfo , err
140
+ return wsInfo , err
149
141
}
150
142
}
151
- return nil , nil , errors .New ("failed with attempt 10 times" )
143
+ return nil , errors .New ("failed with attempt 10 times" )
152
144
}
153
145
154
146
type Extension struct {
0 commit comments