Skip to content

Commit

Permalink
Change package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Oct 26, 2019
1 parent b493f9e commit 2690d45
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package appserver
package appcommon

// Config defines configuration parameters for `Proc`.
type Config struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/app2/appserver/key.go → pkg/app2/appcommon/key.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package appserver
package appcommon

import "github.com/skycoin/dmsg/cipher"

Expand Down
7 changes: 4 additions & 3 deletions pkg/app2/appserver/proc.go → pkg/app2/appcommon/proc.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package appserver
package appcommon

import (
"fmt"
"github.com/skycoin/skywire/pkg/app2/appserver"
"io"
"os/exec"
"path/filepath"
Expand All @@ -16,7 +17,7 @@ type Proc struct {
key Key
config Config
log *logging.Logger
rpcS *Server
rpcS *appserver.Server
cmd *exec.Cmd
}

Expand All @@ -43,7 +44,7 @@ func NewProc(log *logging.Logger, c Config, args []string, stdout, stderr io.Wri
cmd.Stdout = stdout
cmd.Stderr = stderr

rpcS, err := New(logging.MustGetLogger(fmt.Sprintf("app_rpc_server_%s", key)),
rpcS, err := appserver.New(logging.MustGetLogger(fmt.Sprintf("app_rpc_server_%s", key)),
c.SockFile, key)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package appserver
package appcommon

import (
"fmt"
Expand Down Expand Up @@ -35,7 +35,7 @@ func NewProcManager(log *logging.Logger) *ProcManager {

// Run runs the application according to its config and additional args.
func (m *ProcManager) Run(log *logging.Logger, c Config, args []string,
stdout, stderr io.Writer) (apputil.ProcID, error) {
stdout, stderr io.Writer) (ProcID, error) {
if m.Exists(c.Name) {
return 0, errAppAlreadyExists
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package appserver
package appcommon

import (
"sort"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apputil
package appcommon

// ProcID identifies the current instance of an app (an app process).
// The visor node is responsible for starting apps, and the started process
Expand Down
3 changes: 2 additions & 1 deletion pkg/app2/appserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package appserver

import (
"fmt"
"github.com/skycoin/skywire/pkg/app2/appcommon"
"net"
"net/rpc"
"sync"
Expand All @@ -21,7 +22,7 @@ type Server struct {
}

// NewServer constructs server.
func New(log *logging.Logger, sockFile string, appKey Key) (*Server, error) {
func New(log *logging.Logger, sockFile string, appKey appcommon.Key) (*Server, error) {
rpcS := rpc.NewServer()
gateway := newRPCGateway(logging.MustGetLogger(fmt.Sprintf("rpc_server_%s", appKey)))
if err := rpcS.RegisterName(string(appKey), gateway); err != nil {
Expand Down
7 changes: 3 additions & 4 deletions pkg/app2/client.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package app2

import (
"github.com/skycoin/skywire/pkg/app2/appcommon"
"net"
"net/rpc"
"os"

"github.com/skycoin/skywire/pkg/app2/appserver"

"github.com/pkg/errors"
"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/skycoin/src/util/logging"
Expand All @@ -31,7 +30,7 @@ var (
type ClientConfig struct {
VisorPK cipher.PubKey
SockFile string
AppKey appserver.Key
AppKey appcommon.Key
}

// ClientConfigFromEnv creates client config from the ENV args.
Expand Down Expand Up @@ -59,7 +58,7 @@ func ClientConfigFromEnv() (ClientConfig, error) {
return ClientConfig{
VisorPK: visorPK,
SockFile: sockFile,
AppKey: appserver.Key(appKey),
AppKey: appcommon.Key(appKey),
}, nil
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/app2/rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app2

import (
"fmt"
"github.com/skycoin/skywire/pkg/app2/appcommon"
"net/rpc"

"github.com/skycoin/skywire/pkg/app2/appnet"
Expand All @@ -25,11 +26,11 @@ type RPCClient interface {
// rpcClient implements `RPCClient`.
type rpcCLient struct {
rpc *rpc.Client
appKey appserver.Key
appKey appcommon.Key
}

// NewRPCClient constructs new `rpcClient`.
func NewRPCClient(rpc *rpc.Client, appKey appserver.Key) RPCClient {
func NewRPCClient(rpc *rpc.Client, appKey appcommon.Key) RPCClient {
return &rpcCLient{
rpc: rpc,
appKey: appKey,
Expand Down
14 changes: 6 additions & 8 deletions pkg/visor/visor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import (
"syscall"
"time"

"github.com/skycoin/skywire/pkg/app2/apputil"

"github.com/skycoin/skywire/pkg/app2/appserver"
"github.com/skycoin/skywire/pkg/app2/appcommon"

"github.com/skycoin/skywire/pkg/snet"

Expand Down Expand Up @@ -99,7 +97,7 @@ type Node struct {
rpcListener net.Listener
rpcDialers []*noise.RPCClientDialer

procManager *appserver.ProcManager
procManager *appcommon.ProcManager
}

// NewNode constructs new Node.
Expand All @@ -108,7 +106,7 @@ func NewNode(config *Config, masterLogger *logging.MasterLogger) (*Node, error)

node := &Node{
config: config,
procManager: appserver.NewProcManager(logging.MustGetLogger("proc_manager")),
procManager: appcommon.NewProcManager(logging.MustGetLogger("proc_manager")),
}

node.Logger = masterLogger
Expand Down Expand Up @@ -333,7 +331,7 @@ func (node *Node) Close() (err error) {
}

var procs []string
node.procManager.Range(func(name string, _ *appserver.Proc) bool {
node.procManager.Range(func(name string, _ *appcommon.Proc) bool {
procs = append(procs, name)
return true
})
Expand Down Expand Up @@ -407,7 +405,7 @@ func (node *Node) SpawnApp(config *AppConfig, startCh chan<- struct{}) (err erro
return fmt.Errorf("can't bind to reserved port %d", config.Port)
}

appCfg := appserver.Config{
appCfg := appcommon.Config{
Name: config.App,
Version: config.Version,
BinaryDir: node.appsPath,
Expand Down Expand Up @@ -448,7 +446,7 @@ func (node *Node) SpawnApp(config *AppConfig, startCh chan<- struct{}) (err erro
return nil
}

func (node *Node) persistPID(name string, pid apputil.ProcID) {
func (node *Node) persistPID(name string, pid appcommon.ProcID) {
pidF := node.pidFile()
pidFName := pidF.Name()
if err := pidF.Close(); err != nil {
Expand Down

0 comments on commit 2690d45

Please sign in to comment.