Skip to content

Commit

Permalink
Add start of the client implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
  • Loading branch information
ikeydoherty committed Apr 23, 2017
1 parent 55c6a57 commit fb657e2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ include Makefile.gobuild
_PKGS = \
ferry \
ferry/cmd \
ferryc \
ferryd \
ferryd/server \
libeopkg
Expand Down
1 change: 1 addition & 0 deletions src/ferry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"ferry/cmd"
_ "ferryc"
"os"
)

Expand Down
48 changes: 48 additions & 0 deletions src/ferryc/main.go
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,
},
}
}

0 comments on commit fb657e2

Please sign in to comment.