-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add start of the client implementation
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
- Loading branch information
1 parent
55c6a57
commit fb657e2
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ include Makefile.gobuild | |
_PKGS = \ | ||
ferry \ | ||
ferry/cmd \ | ||
ferryc \ | ||
ferryd \ | ||
ferryd/server \ | ||
libeopkg | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ package main | |
|
||
import ( | ||
"ferry/cmd" | ||
_ "ferryc" | ||
"os" | ||
) | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// Copyright © 2017 Ikey Doherty <ikey@solus-project.com> | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package ferryc | ||
|
||
import ( | ||
"net" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
const ( | ||
// UnixSocketPath is the unique socket path on the system for the ferry daemon | ||
UnixSocketPath = "./ferryd.sock" | ||
) | ||
|
||
// A FerryClient is used to communicate with the system ferryd | ||
type FerryClient struct { | ||
client *http.Client | ||
} | ||
|
||
// NewClient will return a new FerryClient for the local unix socket, suitable | ||
// for communicating with the daemon. | ||
func NewClient(address string) *FerryClient { | ||
return &FerryClient{ | ||
client: &http.Client{ | ||
Transport: &http.Transport{ | ||
Dial: func(protocol, address string) (net.Conn, error) { | ||
return net.Dial("unix", UnixSocketPath) | ||
}, | ||
}, | ||
Timeout: 20 * time.Second, | ||
}, | ||
} | ||
} |