Permalink
Browse files

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

…to match new import path
  • Loading branch information...
1 parent a1b214d commit 9abd803879a4759952a720070b04038980d7c01f @skelterjohn skelterjohn committed Jul 27, 2012
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"github.com/bketelsen/skynet/rpc/bsonrpc"
@@ -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"
@@ -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"
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"os"
@@ -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
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"bytes"
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"os"
@@ -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
@@ -8,45 +8,45 @@
package main
import (
- "github.com/bketelsen/skynet/skylib"
+ "github.com/bketelsen/skynet"
"log"
"os"
"strings"
)
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
}
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() {
@@ -1,4 +1,4 @@
-package skylib
+package skynet
// ServiceHandshake is data sent by the service to the client immediately once the connection
// is opened.
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"bytes"
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"fmt"
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"encoding/json"
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"encoding/json"
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"code.google.com/p/gonicetrace/nicetrace"
@@ -1,4 +1,4 @@
-package skylib
+package skynet
import (
"fmt"
View
@@ -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
@@ -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 {
Oops, something went wrong.

0 comments on commit 9abd803

Please sign in to comment.