forked from andygrunwald/megos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogs.go
39 lines (34 loc) · 1.07 KB
/
logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package megos
import (
"net/url"
"strconv"
)
// GetStdOutOfTask will return Stdout of a task.
//
// pid is a single mesos slave node.
// directory is the directory of a single executor,
func (c *Client) GetStdOutOfTask(pid *Pid, directory string) ([]byte, error) {
u := c.getBaseURLForLogs("stdout", pid, directory)
body, err := c.GetBodyOfHTTPResponse(&u)
return body, err
}
// GetStdErrOfTask will return Stdout of a task.
//
// pid is a single mesos slave node.
// directory is the directory of a single executor,
func (c *Client) GetStdErrOfTask(pid *Pid, directory string) ([]byte, error) {
u := c.getBaseURLForLogs("stderr", pid, directory)
body, err := c.GetBodyOfHTTPResponse(&u)
return body, err
}
// getBaseURLForLogs will build the URL to get Stdout or Stderr.
func (c *Client) getBaseURLForLogs(mode string, pid *Pid, directory string) url.URL {
u := url.URL{
// TODO How to support https cluster?
Scheme: "http",
Host: pid.Host + ":" + strconv.Itoa(pid.Port),
Path: "files/download.json",
RawQuery: "path=" + directory + "/" + mode,
}
return u
}