Created
March 22, 2017 21:58
-
-
Save yudai/b1aaf38ed9bbcc1d3717aa853018b811 to your computer and use it in GitHub Desktop.
custom factory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package somepackage | |
import ( | |
"github.com/docker/docker/client" | |
libcomposeclient "github.com/docker/libcompose/docker/client" | |
"github.com/docker/libcompose/project" | |
) | |
type clientFactory struct { | |
client *client.Client | |
} | |
func newClientFactory() (*clientFactory, error) { | |
apiClient, err := libcomposeclient.Create(libcomposeclient.Options{}) | |
if err != nil { | |
return nil, err | |
} | |
return &clientFactory{ | |
client: apiClient.(*client.Client), // to get Close() accessible | |
}, nil | |
} | |
func (s *clientFactory) Create(service project.Service) client.APIClient { | |
return s.client | |
} | |
func (s *clientFactory) Close() { | |
s.client.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment