Skip to content

Commit

Permalink
[trace] add taskInfo for shutdown, add header for http request
Browse files Browse the repository at this point in the history
  • Loading branch information
jzhang28 committed May 11, 2021
1 parent 4051532 commit f11d5cb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/how-to-develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type ComposePlugin interface {
PostKillTask(ctx context.Context, taskInfo *mesos.TaskInfo) error
// Shutdown is invoked prior to executor shutdown in context of Shutdown callback.
Shutdown(executor.ExecutorDriver) error
Shutdown(taskInfo *mesos.TaskInfo, ed executor.ExecutorDriver)
}
```
PreLaunchTask and PostLaunchTask have Context object as first parameter. This is used to pass around parsed compose files so as to avoid loading from files by individual plugins.
Expand Down Expand Up @@ -127,7 +127,7 @@ func (ex *exampleExt) PostKillTask(ctx context.Context, taskInfo *mesos.TaskInfo
return nil
}
func (ex *exampleExt) Shutdown(executor.ExecutorDriver) error {
func (ex *exampleExt) Shutdown(taskInfo *mesos.TaskInfo, ed executor.ExecutorDriver) {
logger.Println("Shutdown Starting")
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pluginimpl/example/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (ex *exampleExt) PostKillTask(ctx context.Context, taskInfo *mesos.TaskInfo
return nil
}

func (ex *exampleExt) Shutdown(executor.ExecutorDriver) error {
func (ex *exampleExt) Shutdown(taskInfo *mesos.TaskInfo, ed executor.ExecutorDriver) error {
logger.Println("Shutdown begin")
return nil
}
2 changes: 1 addition & 1 deletion pluginimpl/general/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (gp *generalExt) PostKillTask(ctx context.Context, taskInfo *mesos.TaskInfo
return err
}

func (gp *generalExt) Shutdown(executor.ExecutorDriver) error {
func (gp *generalExt) Shutdown(taskInfo *mesos.TaskInfo, ed executor.ExecutorDriver) error {
logger.Println("Shutdown begin")
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion utils/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func GenBody(t interface{}) io.Reader {
}

// http post
func PostRequest(ctx context.Context, transport http.RoundTripper, url string, body io.Reader) ([]byte, error) {
func PostRequest(ctx context.Context, transport http.RoundTripper, url string, body io.Reader, header map[string]string) ([]byte, error) {
if transport == nil {
transport = http.DefaultTransport
}
Expand All @@ -51,6 +51,9 @@ func PostRequest(ctx context.Context, transport http.RoundTripper, url string, b
log.Println("Error creating http request : ", err.Error())
return nil, err
}
for k, v := range header {
req.Header.Add(k, v)
}
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
Expand Down

0 comments on commit f11d5cb

Please sign in to comment.