Commits

Marcus von Appen committed 04380bb

go fmt

  • Participants
  • Parent commits d6dabf4

Comments (0)

Files changed (10)

 
 import (
 	"bitbucket.org/marcusva/dmb/service"
+	"bufio"
 	"fmt"
-	"bufio"
 	"net"
 	"os"
 )
 				"could not read reply from server: %v\n", err)
 			os.Exit(1)
 		}
-		reply = reply[0:len(reply)-1]
+		reply = reply[0 : len(reply)-1]
 		switch string(reply) {
 		case service.AnswerOK:
 			fmt.Fprintf(os.Stderr, "processing dead messages initiated\n")
 				"could not read reply from server: %v\n", err)
 			os.Exit(1)
 		}
-		reply = reply[0:len(reply)-1]
+		reply = reply[0 : len(reply)-1]
 		switch string(reply) {
 		case service.AnswerOK:
 			fmt.Fprintf(os.Stderr, "inspection done\n")
 
 import (
 	"bitbucket.org/marcusva/dmb/log"
+	"bitbucket.org/marcusva/dmb/service"
 	"bitbucket.org/marcusva/dmb/storage"
-	"bitbucket.org/marcusva/dmb/service"
 	"flag"
 	"fmt"
 	"github.com/msbranco/goconfig"
 
 	// Create the storage back-end
 	sentries, err := conf.GetOptions("storage")
-	if err != nil  {
+	if err != nil {
 		fmt.Fprintf(os.Stderr, "could not find storage: %s\n", err)
 		os.Exit(1)
 	}
 
 	// Startup params for the different service parts
 	// (web, command and message broker)
-	params := map[string]string {
-		"host": "",
+	params := map[string]string{
+		"host":                 "",
 		"interval_resend_dead": "",
 	}
 
 )
 
 const (
-//	PID_PATH          = "/var/run"
-	PID_PATH          = "/tmp"
-	PID_FILE          = "dmb.pid"
+	//	PID_PATH          = "/var/run"
+	PID_PATH = "/tmp"
+	PID_FILE = "dmb.pid"
 )
 
 func daemonRunning() (bool, int) {
 	// TODO: how to deal with daemons on Win32? We would need to query
 	// it via the service APIs
 	fname := path.Join(PID_PATH, PID_FILE)
-	_, err := os.Stat(fname);
+	_, err := os.Stat(fname)
 	if os.IsNotExist(err) {
 		return false, 0
 	}

File dmb_windows.go

 	return true, pid
 }
 
-func daemonize () {
+func daemonize() {
 	// does not do anything
 	fmt.Fprintln(os.Stderr, daemonMessage)
 	os.Exit(1)

File service/broker.go

 	log.Log.Debugf("Transform() for service [%s] invoked", service.Name)
 	buf, err := ioutil.ReadAll(req.Body)
 	if err != nil {
-	 	log.Log.Errorf("Error on read: %s", err)
-	 	return
+		log.Log.Errorf("Error on read: %s", err)
+		return
 	}
 	// Invalid sender
 	sender, err := srv.getSender(req.RemoteAddr)
 	if err != nil {
-	 	log.Log.Error(err)
+		log.Log.Error(err)
 		return
 	}
 	msg := message.New(sender.Name, service.Name, buf, args)

File service/cmdservice.go

 
 import (
 	"bitbucket.org/marcusva/dmb/log"
+	"bufio"
 	"fmt"
-	"bufio"
 	"io"
 	"net"
 	"os"
 
 const (
 	CommandSocket = "/tmp/dmb-daemon.%d"
-	CmdInspect = "inspect"
-	CmdProcess = "dead"
-	AnswerOK = "OK"
-	AnswerError = "ERROR"
+	CmdInspect    = "inspect"
+	CmdProcess    = "dead"
+	AnswerOK      = "OK"
+	AnswerError   = "ERROR"
 )
 
 func GetCommandSocket(pid int) string {
 }
 
 type CommandService struct {
-	pid int
+	pid     int
 	service *Broker
 }
 
-func NewCommandService(srv *Broker) *CommandService{
+func NewCommandService(srv *Broker) *CommandService {
 	return &CommandService{
-		pid: os.Getpid(),
+		pid:     os.Getpid(),
 		service: srv,
 	}
 }
 			log.Log.Errorf("error on read: %s", err)
 			return
 		}
-		command = command[0:len(command)-1]
+		command = command[0 : len(command)-1]
 		log.Log.Debugf("CommandService received '%s'", command)
 		switch command {
 		case CmdProcess:
 			go cmd.service.resendDead()
-		fmt.Fprintf(c, "%s\n", AnswerOK)
+			fmt.Fprintf(c, "%s\n", AnswerOK)
 		case CmdInspect:
 			fmt.Fprintf(c, "%s\n", AnswerOK)
 		default:
 func (cmd *CommandService) Run() error {
 	log.Log.Info("Starting CommandService")
 	socket := fmt.Sprintf(CommandSocket, cmd.pid)
-	ln, err := net.Listen("unix", socket);
+	ln, err := net.Listen("unix", socket)
 	if err != nil {
 		return err
 	}

File service/cronjob.go

 func NewSingleJob(cmd func()) *SingleJob {
 	return &SingleJob{
 		running: false,
-		Job: cron.FuncJob(cmd),
+		Job:     cron.FuncJob(cmd),
 	}
 }
 

File service/service.go

 // Creates a new Sender
 func NewSender(name, address, cert string) *Sender {
 	return &Sender{
-		Name: name,
-		Address: address,
+		Name:        name,
+		Address:     address,
 		Certificate: cert,
 		LastConnect: time.Time{},
 	}
 // Creates a new Receiver
 func NewReceiver(name, address, cert string) *Receiver {
 	return &Receiver{
-		Name: name,
-		Address: address,
+		Name:        name,
+		Address:     address,
 		Certificate: cert,
 		LastConnect: time.Time{},
 	}

File service/webservice.go

 
 import (
 	"bitbucket.org/marcusva/dmb/log"
+	"fmt"
 	"github.com/hoisie/web"
-	"fmt"
 	"html/template"
 	"net/http"
 )
 
 type WebService struct {
-	Broker   *Broker
+	Broker    *Broker
 	Templates map[string]*template.Template
 }
 
 func NewWebService(b *Broker) *WebService {
 	ws := &WebService{
-		Broker: b,
+		Broker:    b,
 		Templates: make(map[string]*template.Template),
 	}
 	ws.Templates["info"] = template.Must(

File storage/filestorage.go

 
 // A simple file storage back-end
 type FileStorage struct {
-	basePath string
+	basePath     string
 	storagePaths map[string]string
 }
 
 
 func NewFileStorage(path string) *FileStorage {
 	return &FileStorage{
-		basePath: path,
+		basePath:     path,
 		storagePaths: make(map[string]string),
 	}
 }