Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

host API cleanup #729

Merged
merged 8 commits into from Jan 15, 2015
Merged

host API cleanup #729

merged 8 commits into from Jan 15, 2015

Conversation

warpfork
Copy link
Contributor

One tiny change suggested by @archseer; and a rename that will make sense as the volumes API comes in next to this.

@@ -252,7 +252,7 @@ func runDaemon(args *docopt.Args) {

// Check if we are the leader so that we can use the cluster functions directly
sampiCluster := sampi.NewCluster(sampi.NewState())
sampiAPI := sampi.NewHTTPAPI(sampiCluster)
sampiAPI := &sampi.HttpAPI{sampiCluster}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vet will complain about the missing field name

@@ -54,11 +54,11 @@ func (h *Host) streamEvents(id string, w http.ResponseWriter) error {
return nil
}

type httpAPI struct {
type hostAPI struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or actually -- maybe jobAPI?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

@archseer
Copy link
Contributor

LGTM, pending that rename

@archseer
Copy link
Contributor

We could also get rid of sampi.NewCluster. This will need to be changed then:

sampiCluster := sampi.NewCluster(sampi.NewState())

@archseer
Copy link
Contributor

Ah actually, I'd change sampi.NewCluster to be without arguments and create a new state object within the constructor.

var jobStream stream.Stream
sh.BeforeExit(func() {
if jobStream != nil {
jobStream.Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like unnecessary cleanup?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said in the commit, I found it easier to follow with the jobStream logic being all in one section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, closing the stream on exit doesn't really do much, the fds will be reaped by the kernel at exit anyway.

warpfork and others added 3 commits January 13, 2015 23:22
Also, rename hostAPI to jobAPI (this seems to accurately describe all functions in the current group, and makes way for more features we'll be adding to the host shortly).

Signed-off-by: Eric Myhre <eric@flynn.io>
Signed-off-by: Eric Myhre <eric@flynn.io>
Since the manifest format has changed, h.Metadata will now always be nil (we're
creating a new blank host object after all). ID can also be directly set, this
was different in the past as we did some pointer trickery.

Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
@warpfork warpfork force-pushed the host-api-cleanup branch 2 times, most recently from 1ea1b16 to be89227 Compare January 14, 2015 07:37
This will be dropped on the floor by the OS when the process terminates anyway; no special action is required.

Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
@titanous
Copy link
Contributor

LGTM, though a few commit messages need a pkg/ prefix.

Blaž Hrastnik added 4 commits January 15, 2015 11:00
Since stream objects are now generic, we can make a more generic client method
for them. Note that since the method doesn't provide a way to specify headers,
StreamJobEvents on the controller cannot be simplified (yet).

Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
This gets rid of more references to rpcplus; leaving discoverd the last
component to still reference it.

Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Since we're no longer opening a permanently open socket to the host, there is no
cleanup needed. The current method just called httpclient's Close() method,
which will no-op (it only closes the dialer if dialClose is set, which is nil in
this particular client).

Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
archseer pushed a commit that referenced this pull request Jan 15, 2015
@archseer archseer merged commit b729e3c into master Jan 15, 2015
@archseer archseer deleted the host-api-cleanup branch January 15, 2015 02:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants