Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moved skynet/skylib to skynet, renamed package from skylib to skynet …

…to match new import path
  • Loading branch information...
commit 9abd803879a4759952a720070b04038980d7c01f 1 parent a1b214d
@skelterjohn skelterjohn authored
View
2  skylib/admin.go → admin.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"github.com/bketelsen/skynet/rpc/bsonrpc"
View
4 skylib/client.go → client.go
@@ -1,11 +1,11 @@
-package skylib
+package skynet
import (
"bytes"
"encoding/json"
"errors"
"github.com/bketelsen/skynet/rpc/bsonrpc"
- "github.com/bketelsen/skynet/skylib/util"
+ "github.com/bketelsen/skynet/util"
"launchpad.net/mgo/v2/bson"
"math/rand"
"net"
View
2  skylib/config.go → config.go
@@ -6,7 +6,7 @@
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-package skylib
+package skynet
import (
"errors"
View
2  skylib/config_test.go → config_test.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"os"
View
2  skylib/doc.go → doc.go
@@ -25,4 +25,4 @@ Services -
SkyNet uses Doozer to store configuration data about the available services. Configuration changes are pushed to Doozer, causing connected clients to immediately become aware of changed configurations.
*/
-package skylib
+package skynet
View
2  skylib/doozer.go → doozer.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"bytes"
View
2  skylib/doozer_test.go → doozer_test.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"os"
View
10 examples/client/client.go
@@ -2,7 +2,7 @@ package main
import (
"fmt"
- "github.com/bketelsen/skynet/skylib"
+ "github.com/bketelsen/skynet"
"os"
"os/signal"
"syscall"
@@ -11,17 +11,17 @@ import (
func main() {
c := make(chan os.Signal, 1)
- config := &skylib.ClientConfig{
- DoozerConfig: &skylib.DoozerConfig{
+ config := &skynet.ClientConfig{
+ DoozerConfig: &skynet.DoozerConfig{
Uri: "127.0.0.1:8046",
AutoDiscover: true,
},
}
var err error
- config.Log = skylib.NewConsoleLogger(os.Stderr)
+ config.Log = skynet.NewConsoleLogger(os.Stderr)
- client := skylib.NewClient(config)
+ client := skynet.NewClient(config)
// This will not fail if no services currently exist, as connections are created on demand
// this saves from chicken and egg issues with dependencies between services
View
22 examples/service/service.go
@@ -8,7 +8,7 @@
package main
import (
- "github.com/bketelsen/skynet/skylib"
+ "github.com/bketelsen/skynet"
"log"
"os"
"strings"
@@ -16,17 +16,17 @@ import (
type TestService struct{}
-func (s *TestService) Registered(service *skylib.Service) {}
-func (s *TestService) Unregistered(service *skylib.Service) {}
-func (s *TestService) Started(service *skylib.Service) {}
-func (s *TestService) Stopped(service *skylib.Service) {}
+func (s *TestService) Registered(service *skynet.Service) {}
+func (s *TestService) Unregistered(service *skynet.Service) {}
+func (s *TestService) Started(service *skynet.Service) {}
+func (s *TestService) Stopped(service *skynet.Service) {}
func NewTestService() *TestService {
r := &TestService{}
return r
}
-func (s *TestService) Upcase(requestInfo *skylib.RequestInfo, in map[string]interface{}, out map[string]interface{}) (err error) {
+func (s *TestService) Upcase(requestInfo *skynet.RequestInfo, in map[string]interface{}, out map[string]interface{}) (err error) {
out["data"] = strings.ToUpper(in["data"].(string))
return
}
@@ -34,19 +34,19 @@ func (s *TestService) Upcase(requestInfo *skylib.RequestInfo, in map[string]inte
func main() {
testService := NewTestService()
- config, _ := skylib.GetServiceConfigFromFlags()
+ config, _ := skynet.GetServiceConfigFromFlags()
config.Name = "TestService"
config.Version = "1"
config.Region = "Clearwater"
var err error
- mlogger, err := skylib.NewMongoLogger("localhost", "skynet", "log", config.UUID)
- clogger := skylib.NewConsoleLogger(os.Stdout)
- config.Log = skylib.NewMultiLogger(mlogger, clogger)
+ mlogger, err := skynet.NewMongoLogger("localhost", "skynet", "log", config.UUID)
+ clogger := skynet.NewConsoleLogger(os.Stdout)
+ config.Log = skynet.NewMultiLogger(mlogger, clogger)
if err != nil {
config.Log.Item("Could not connect to mongo db for logging")
}
- service := skylib.CreateService(testService, config)
+ service := skynet.CreateService(testService, config)
// handle panic so that we remove ourselves from the pool in case of catastrophic failure
defer func() {
View
2  skylib/handshake.go → handshake.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
// ServiceHandshake is data sent by the service to the client immediately once the connection
// is opened.
View
2  skylib/logger.go → logger.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"bytes"
View
2  skylib/logmessages.go → logmessages.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"fmt"
View
2  skylib/query.go → query.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"encoding/json"
View
2  skylib/service.go → service.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"encoding/json"
View
2  skylib/servicerpc.go → servicerpc.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"code.google.com/p/gonicetrace/nicetrace"
View
2  skylib/servicerpc_test.go → servicerpc_test.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"fmt"
View
22 sky/admin.go
@@ -1,42 +1,42 @@
package main
import (
+ "github.com/bketelsen/skynet"
"github.com/bketelsen/skynet/rpc/bsonrpc"
- "github.com/bketelsen/skynet/skylib"
"net"
"net/rpc"
"os"
)
-func doRegister(rpcClient *rpc.Client, log skylib.Logger) {
- var args skylib.RegisterParams
- var reply skylib.RegisterReturns
+func doRegister(rpcClient *rpc.Client, log skynet.Logger) {
+ var args skynet.RegisterParams
+ var reply skynet.RegisterReturns
err := rpcClient.Call("Admin.Register", args, &reply)
if err != nil {
log.Item(err)
}
}
-func doUnregister(rpcClient *rpc.Client, log skylib.Logger) {
- var args skylib.UnregisterParams
- var reply skylib.UnregisterReturns
+func doUnregister(rpcClient *rpc.Client, log skynet.Logger) {
+ var args skynet.UnregisterParams
+ var reply skynet.UnregisterReturns
err := rpcClient.Call("Admin.Unregister", args, &reply)
if err != nil {
log.Item(err)
}
}
-func Register(q *skylib.Query) {
+func Register(q *skynet.Query) {
doSomething(q, doRegister)
}
-func Unregister(q *skylib.Query) {
+func Unregister(q *skynet.Query) {
doSomething(q, doUnregister)
}
-func doSomething(q *skylib.Query, do func(*rpc.Client, skylib.Logger)) {
+func doSomething(q *skynet.Query, do func(*rpc.Client, skynet.Logger)) {
- log := skylib.NewConsoleLogger(os.Stderr)
+ log := skynet.NewConsoleLogger(os.Stderr)
for _, instance := range q.FindInstances() {
conn, err := net.Dial("tcp", instance.Config.AdminAddr.String())
if err != nil {
View
44 sky/daemon.go
@@ -4,7 +4,7 @@ import (
"bufio"
"errors"
"fmt"
- "github.com/bketelsen/skynet/skylib"
+ "github.com/bketelsen/skynet"
"io"
"log"
"os"
@@ -18,18 +18,18 @@ import (
//
// Daemon() will run the "SkynetDeployment" service, which can be used to remotely spawn
// new services on the host.
-func Daemon(q *skylib.Query, argv []string) {
+func Daemon(q *skynet.Query, argv []string) {
- config, args := skylib.GetServiceConfigFromFlags(argv...)
+ config, args := skynet.GetServiceConfigFromFlags(argv...)
config.Name = "SkynetDaemon"
config.Version = "1"
config.Region = "Jersey"
var err error
- mlogger, err := skylib.NewMongoLogger("localhost", "skynet", "log", config.UUID)
- clogger := skylib.NewConsoleLogger(os.Stdout)
- config.Log = skylib.NewMultiLogger(mlogger, clogger)
+ mlogger, err := skynet.NewMongoLogger("localhost", "skynet", "log", config.UUID)
+ clogger := skynet.NewConsoleLogger(os.Stdout)
+ config.Log = skynet.NewMultiLogger(mlogger, clogger)
if err != nil {
config.Log.Item("Could not connect to mongo db for logging")
}
@@ -39,7 +39,7 @@ func Daemon(q *skylib.Query, argv []string) {
Services: map[string]*SubService{},
}
- service := skylib.CreateService(deployment, config)
+ service := skynet.CreateService(deployment, config)
// handle panic so that we remove ourselves from the pool in case of catastrophic failure
defer func() {
@@ -94,28 +94,28 @@ func deployConfig(s *SkynetDaemon, cfg string) (err error) {
}
servicePath := line[:split]
args := strings.TrimSpace(line[split:])
- s.Deploy(&skylib.RequestInfo{}, M{"service": servicePath, "args": args}, &M{})
+ s.Deploy(&skynet.RequestInfo{}, M{"service": servicePath, "args": args}, &M{})
}
return
}
// SkynetDaemon is a service for administering other services
type SkynetDaemon struct {
- Log skylib.Logger
+ Log skynet.Logger
Services map[string]*SubService
serviceLock sync.Mutex
}
-func (s *SkynetDaemon) Registered(service *skylib.Service) {}
-func (s *SkynetDaemon) Unregistered(service *skylib.Service) {}
-func (s *SkynetDaemon) Started(service *skylib.Service) {}
-func (s *SkynetDaemon) Stopped(service *skylib.Service) {
- s.StopAllSubServices(&skylib.RequestInfo{}, M{}, &M{})
+func (s *SkynetDaemon) Registered(service *skynet.Service) {}
+func (s *SkynetDaemon) Unregistered(service *skynet.Service) {}
+func (s *SkynetDaemon) Started(service *skynet.Service) {}
+func (s *SkynetDaemon) Stopped(service *skynet.Service) {
+ s.StopAllSubServices(&skynet.RequestInfo{}, M{}, &M{})
}
-func (s *SkynetDaemon) Deploy(requestInfo *skylib.RequestInfo, in M, out *M) (err error) {
+func (s *SkynetDaemon) Deploy(requestInfo *skynet.RequestInfo, in M, out *M) (err error) {
*out = map[string]interface{}{}
- uuid := skylib.UUID()
+ uuid := skynet.UUID()
(*out)["uuid"] = uuid
servicePath := in["service"].(string)
@@ -154,12 +154,12 @@ func (m M) String(key string) (val string, ok bool) {
return
}
-func (s *SkynetDaemon) ListSubServices(requestInfo *skylib.RequestInfo, in M, out M) (err error) {
+func (s *SkynetDaemon) ListSubServices(requestInfo *skynet.RequestInfo, in M, out M) (err error) {
out["Services"] = s.Services
return
}
-func (s *SkynetDaemon) StopAllSubServices(requestInfo *skylib.RequestInfo, in M, out *M) (err error) {
+func (s *SkynetDaemon) StopAllSubServices(requestInfo *skynet.RequestInfo, in M, out *M) (err error) {
*out = map[string]interface{}{}
var uuids []string
s.serviceLock.Lock()
@@ -176,7 +176,7 @@ func (s *SkynetDaemon) StopAllSubServices(requestInfo *skylib.RequestInfo, in M,
return
}
-func (s *SkynetDaemon) StartAllSubServices(requestInfo *skylib.RequestInfo, in M, out *M) (err error) {
+func (s *SkynetDaemon) StartAllSubServices(requestInfo *skynet.RequestInfo, in M, out *M) (err error) {
*out = map[string]interface{}{}
var uuids []string
s.serviceLock.Lock()
@@ -193,7 +193,7 @@ func (s *SkynetDaemon) StartAllSubServices(requestInfo *skylib.RequestInfo, in M
return
}
-func (s *SkynetDaemon) StartSubService(requestInfo *skylib.RequestInfo, in M, out *M) (err error) {
+func (s *SkynetDaemon) StartSubService(requestInfo *skynet.RequestInfo, in M, out *M) (err error) {
*out = map[string]interface{}{}
uuid, ok := in.String("uuid")
if !ok {
@@ -210,7 +210,7 @@ func (s *SkynetDaemon) StartSubService(requestInfo *skylib.RequestInfo, in M, ou
return
}
-func (s *SkynetDaemon) StopSubService(requestInfo *skylib.RequestInfo, in M, out *M) (err error) {
+func (s *SkynetDaemon) StopSubService(requestInfo *skynet.RequestInfo, in M, out *M) (err error) {
*out = map[string]interface{}{}
uuid, ok := in.String("uuid")
if !ok {
@@ -222,7 +222,7 @@ func (s *SkynetDaemon) StopSubService(requestInfo *skylib.RequestInfo, in M, out
return
}
-func (s *SkynetDaemon) RestartSubService(requestInfo *skylib.RequestInfo, in M, out *M) (err error) {
+func (s *SkynetDaemon) RestartSubService(requestInfo *skynet.RequestInfo, in M, out *M) (err error) {
*out = map[string]interface{}{}
uuid, ok := in.String("uuid")
if !ok {
View
22 sky/remote.go
@@ -2,12 +2,12 @@ package main
import (
"fmt"
- "github.com/bketelsen/skynet/skylib"
+ "github.com/bketelsen/skynet"
"os"
)
// Remote() uses the SkynetDaemon service to remotely manage services.
-func Remote(q *skylib.Query, args []string) {
+func Remote(q *skynet.Query, args []string) {
if len(args) == 0 {
remoteHelp()
return
@@ -41,20 +41,20 @@ func Remote(q *skylib.Query, args []string) {
return
}
-func getDaemonServiceClient(q *skylib.Query) (client *skylib.Client, service *skylib.ServiceClient) {
- config := &skylib.ClientConfig{
- DoozerConfig: &skylib.DoozerConfig{
+func getDaemonServiceClient(q *skynet.Query) (client *skynet.Client, service *skynet.ServiceClient) {
+ config := &skynet.ClientConfig{
+ DoozerConfig: &skynet.DoozerConfig{
Uri: "127.0.0.1:8046",
AutoDiscover: true,
},
}
- config.Log = skylib.NewConsoleLogger(os.Stderr)
+ config.Log = skynet.NewConsoleLogger(os.Stderr)
- client = skylib.NewClient(config)
+ client = skynet.NewClient(config)
registered := true
- query := &skylib.Query{
+ query := &skynet.Query{
DoozerConn: client.DoozerConn,
Service: "SkynetDaemon",
Host: "127.0.0.1",
@@ -64,7 +64,7 @@ func getDaemonServiceClient(q *skylib.Query) (client *skylib.Client, service *sk
return
}
-func remoteList(q *skylib.Query) {
+func remoteList(q *skynet.Query) {
_, service := getDaemonServiceClient(q)
// This on the other hand will fail if it can't find a service to connect to
@@ -80,11 +80,11 @@ func remoteList(q *skylib.Query) {
fmt.Println(ret)
}
-func remoteDeploy(q *skylib.Query, servicePath string, serviceArgs []string) {
+func remoteDeploy(q *skynet.Query, servicePath string, serviceArgs []string) {
}
-func remoteStart(q *skylib.Query, uuid string) {
+func remoteStart(q *skynet.Query, uuid string) {
_, service := getDaemonServiceClient(q)
// This on the other hand will fail if it can't find a service to connect to
View
36 sky/sky.go
@@ -4,7 +4,7 @@ import (
"bufio"
"flag"
"fmt"
- "github.com/bketelsen/skynet/skylib"
+ "github.com/bketelsen/skynet"
"os"
"strconv"
"strings"
@@ -28,12 +28,12 @@ var (
RegisteredFlag *string = flag.String("registered", "", "registered")
)
-var DC skylib.DoozerConnection
+var DC skynet.DoozerConnection
func main() {
flag.Parse()
- query := &skylib.Query{
+ query := &skynet.Query{
DoozerConn: Doozer(),
Service: *ServiceNameFlag,
Version: *VersionFlag,
@@ -72,7 +72,7 @@ func main() {
}
}
-func Doozer() skylib.DoozerConnection {
+func Doozer() skynet.DoozerConnection {
if DC == nil {
DC = Connect()
}
@@ -80,7 +80,7 @@ func Doozer() skylib.DoozerConnection {
return DC
}
-func Connect() skylib.DoozerConnection {
+func Connect() skynet.DoozerConnection {
defer func() {
if r := recover(); r != nil {
fmt.Println("Failed to connect to Doozer")
@@ -89,13 +89,13 @@ func Connect() skylib.DoozerConnection {
}()
// TODO: This needs to come from command line, or environment variable
- conn := skylib.NewDoozerConnection(*DoozerHost, "", false, nil) // nil as the last param will default to a Stdout logger
+ conn := skynet.NewDoozerConnection(*DoozerHost, "", false, nil) // nil as the last param will default to a Stdout logger
conn.Connect()
return conn
}
-func ListInstances(q *skylib.Query) {
+func ListInstances(q *skynet.Query) {
var regFlag *bool
if *RegisteredFlag == "true" {
@@ -121,7 +121,7 @@ func ListInstances(q *skylib.Query) {
}
}
-func ListHosts(q *skylib.Query) {
+func ListHosts(q *skynet.Query) {
results := q.FindHosts()
for _, host := range results {
@@ -129,7 +129,7 @@ func ListHosts(q *skylib.Query) {
}
}
-func ListRegions(q *skylib.Query) {
+func ListRegions(q *skynet.Query) {
results := q.FindRegions()
for _, region := range results {
@@ -137,7 +137,7 @@ func ListRegions(q *skylib.Query) {
}
}
-func ListServices(q *skylib.Query) {
+func ListServices(q *skynet.Query) {
results := q.FindServices()
for _, service := range results {
@@ -145,7 +145,7 @@ func ListServices(q *skylib.Query) {
}
}
-func ListServiceVersions(q *skylib.Query) {
+func ListServiceVersions(q *skynet.Query) {
if *ServiceNameFlag == "" {
fmt.Println("Service name is required")
return
@@ -158,27 +158,27 @@ func ListServiceVersions(q *skylib.Query) {
}
}
-func PrintTopology(q *skylib.Query) {
- topology := make(map[string]map[string]map[string]map[string][]*skylib.Service)
+func PrintTopology(q *skynet.Query) {
+ topology := make(map[string]map[string]map[string]map[string][]*skynet.Service)
results := q.FindInstances()
// Build topology hash first
for _, instance := range results {
if topology[instance.Config.Region] == nil {
- topology[instance.Config.Region] = make(map[string]map[string]map[string][]*skylib.Service)
+ topology[instance.Config.Region] = make(map[string]map[string]map[string][]*skynet.Service)
}
if topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress] == nil {
- topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress] = make(map[string]map[string][]*skylib.Service)
+ topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress] = make(map[string]map[string][]*skynet.Service)
}
if topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name] == nil {
- topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name] = make(map[string][]*skylib.Service)
+ topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name] = make(map[string][]*skynet.Service)
}
if topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name][instance.Config.Version] == nil {
- topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name][instance.Config.Version] = make([]*skylib.Service, 0)
+ topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name][instance.Config.Version] = make([]*skynet.Service, 0)
}
topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name][instance.Config.Version] = append(topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name][instance.Config.Version], instance)
@@ -264,7 +264,7 @@ func InteractiveShell() {
fmt.Println("Skynet Interactive Shell")
prompt()
- query := &skylib.Query{
+ query := &skynet.Query{
DoozerConn: doozer,
}
View
4 sky/subservice.go
@@ -1,7 +1,7 @@
package main
import (
- "github.com/bketelsen/skynet/skylib"
+ "github.com/bketelsen/skynet"
"github.com/kballard/go-shellquote"
"go/build"
"os"
@@ -31,7 +31,7 @@ type SubService struct {
startMutex sync.Mutex
}
-func NewSubService(log skylib.Logger, servicePath, args, uuid string) (ss *SubService, err error) {
+func NewSubService(log skynet.Logger, servicePath, args, uuid string) (ss *SubService, err error) {
ss = &SubService{
ServicePath: servicePath,
Args: args,
View
0  skylib/util/roundrobin.go → util/roundrobin.go
File renamed without changes
View
0  skylib/util/roundrobin_test.go → util/roundrobin_test.go
File renamed without changes
View
2  skylib/uuid.go → uuid.go
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"crypto/rand"
Please sign in to comment.
Something went wrong with that request. Please try again.