Commit c3af3514 authored by Stefan Dähling's avatar Stefan Dähling
Browse files

move ams cli back to separate pkg

parent f825ae60
Pipeline #404899 passed with stages
in 5 minutes and 15 seconds
......@@ -48,7 +48,7 @@ COPY go.sum .
RUN go mod download
COPY cmd/agency cmd/agency
COPY pkg/agency pkg/agency
COPY pkg/ams pkg/ams
COPY pkg/ams/client pkg/ams/client
COPY pkg/logger/client pkg/logger/client
COPY pkg/df/client pkg/df/client
COPY pkg/schemas pkg/schemas
......
......@@ -47,7 +47,7 @@ COPY go.mod .
COPY go.sum .
RUN go mod download
COPY pkg/agency pkg/agency
COPY pkg/ams pkg/ams
COPY pkg/ams/client pkg/ams/client
COPY pkg/logger/client pkg/logger/client
COPY pkg/df/client pkg/df/client
COPY pkg/schemas pkg/schemas
......
......@@ -50,7 +50,7 @@ COPY cmd/frontend cmd/frontend
COPY pkg/frontend pkg/frontend
COPY pkg/common pkg/common
COPY pkg/schemas pkg/schemas
COPY pkg/ams pkg/ams
COPY pkg/ams/client pkg/ams/client
COPY pkg/df/client pkg/df/client
COPY pkg/logger/client pkg/logger/client
COPY web web
......
......@@ -48,7 +48,7 @@ COPY go.sum .
RUN go mod download
COPY cmd/plugnplay cmd/plugnplay
COPY pkg/plugnplay pkg/plugnplay
COPY pkg/ams pkg/ams
COPY pkg/ams/client pkg/ams/client
COPY pkg/schemas pkg/schemas
COPY pkg/common pkg/common
ENV PATH="/clonemap:${PATH}"
......
......@@ -58,7 +58,7 @@ import (
"syscall"
"time"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams"
amscli "git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/status"
)
......@@ -75,7 +75,7 @@ type Agency struct {
msgIn chan []schemas.ACLMessage
logger *loggerClient
mqtt *mqttClient
amsClient *ams.Client
amsClient *amscli.Client
logInfo *log.Logger // logger for info logging
logError *log.Logger // logger for error logging
}
......@@ -89,7 +89,7 @@ func StartAgency(task func(*Agent) error) (err error) {
remoteAgents: make(map[int]*Agent),
remoteAgencies: make(map[string]*remoteAgency),
msgIn: make(chan []schemas.ACLMessage, 1000),
amsClient: ams.NewClient(time.Second*60, time.Second*1, 4),
amsClient: amscli.New(time.Second*60, time.Second*1, 4),
logError: log.New(os.Stderr, "[ERROR] ", log.LstdFlags),
}
err = agency.init()
......
......@@ -51,6 +51,7 @@ import (
"testing"
"time"
amscli "git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/common/httpreply"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
......@@ -113,7 +114,7 @@ func stubHandler(w http.ResponseWriter, r *http.Request) {
// dummyClient makes requests to ams and terminates ams server at end
func dummyClient(s *http.Server, t *testing.T) {
time.Sleep(time.Second * 1)
amsClient := NewClient(time.Second*60, time.Second*1, 4)
amsClient := amscli.New(time.Second*60, time.Second*1, 4)
amsClient.Host = "localhost"
amsClient.Port = 10000
......
......@@ -42,9 +42,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// contains code for interaction with ams
package ams
// Package client contains code for interaction with ams
package client
import (
"encoding/json"
......@@ -254,8 +253,8 @@ func (cli *Client) prefix() (ret string) {
return
}
// NewClient creates a new AMS client
func NewClient(timeout time.Duration, del time.Duration, numRet int) (cli *Client) {
// New creates a new AMS client
func New(timeout time.Duration, del time.Duration, numRet int) (cli *Client) {
cli = &Client{
httpClient: &http.Client{Timeout: timeout},
Host: "ams",
......
......@@ -47,18 +47,18 @@ package frontend
import (
"time"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams"
amscli "git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams/client"
)
// Frontend frontend
type Frontend struct {
amsClient *ams.Client
amsClient *amscli.Client
}
// StartFrontend start
func StartFrontend() (err error) {
fe := &Frontend{
amsClient: ams.NewClient(time.Second*60, time.Second*1, 4),
amsClient: amscli.New(time.Second*60, time.Second*1, 4),
}
fe.listen()
return
......
......@@ -51,7 +51,7 @@ import (
"strconv"
"sync"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams"
amscli "git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
mqtt "github.com/eclipse/paho.mqtt.golang"
)
......@@ -65,12 +65,12 @@ type mqttClient struct {
mutex *sync.Mutex // mutex for message inbox map
logError *log.Logger
logInfo *log.Logger
amsClient *ams.Client
amsClient *amscli.Client
}
// newMQTTClient creates a new mqtt agency client
func newMQTTClient(svc string, port int, name string, logErr *log.Logger,
logInf *log.Logger, amsClient *ams.Client) (cli *mqttClient) {
logInf *log.Logger, amsClient *amscli.Client) (cli *mqttClient) {
cli = &mqttClient{
brokerSvc: svc,
brokerPort: port,
......
......@@ -54,7 +54,7 @@ import (
"os"
"time"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams"
amscli "git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams/client"
)
// PnP implements the plug and play mechanism
......@@ -62,14 +62,14 @@ type PnP struct {
logInfo *log.Logger // logger for info logging
logError *log.Logger // logger for error logging
mqttCli *mqttClient
amsClient *ams.Client
amsClient *amscli.Client
}
// StartPnP starts an PnP instance. It initializes the storage object and starts the API server.
func StartPnP() (err error) {
pnp := &PnP{
logError: log.New(os.Stderr, "[ERROR] ", log.LstdFlags),
amsClient: ams.NewClient(time.Second*60, time.Second*1, 4),
amsClient: amscli.New(time.Second*60, time.Second*1, 4),
}
// create storage and deployment object according to specified deployment type
err = pnp.init()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment