temporarily replace bson with gob
This commit is contained in:
parent
fa07d82461
commit
cf27863841
5 changed files with 20 additions and 22 deletions
|
@ -4,15 +4,23 @@ import (
|
|||
"bytes"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/youtube/vitess/go/bson"
|
||||
//"github.com/youtube/vitess/go/bson"
|
||||
"encoding/gob"
|
||||
)
|
||||
|
||||
func encode(v interface{}) ([]byte, error) {
|
||||
return bson.Marshal(v)
|
||||
var buf bytes.Buffer
|
||||
var err = gob.NewEncoder(&buf).Encode(v)
|
||||
return buf.Bytes(), err
|
||||
//return bson.Marshal(v)
|
||||
}
|
||||
|
||||
func decode(raw []byte, v interface{}) error {
|
||||
return bson.Unmarshal(raw, v)
|
||||
var buf bytes.Buffer
|
||||
buf.Write(raw)
|
||||
var err = gob.NewDecoder(&buf).Decode(v)
|
||||
return err
|
||||
//return bson.Unmarshal(raw, v)
|
||||
}
|
||||
|
||||
func get(t *bolt.Tx, bucket, key []byte, v interface{}) error {
|
||||
|
@ -20,7 +28,7 @@ func get(t *bolt.Tx, bucket, key []byte, v interface{}) error {
|
|||
if raw == nil {
|
||||
return ErrKeyNotFound
|
||||
}
|
||||
return bson.Unmarshal(raw, v)
|
||||
return decode(raw, v)
|
||||
}
|
||||
|
||||
func raw(t *bolt.Tx, bucket, key []byte) ([]byte, error) {
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
repo.subscribe(fullName, function(event) {
|
||||
repos.subscribe(fullName, function(event) {
|
||||
var added = false;
|
||||
for (var i=0;i<$scope.builds.length;i++) {
|
||||
var build = $scope.builds[i];
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* ReposCtrl responsible for rendering the user's
|
||||
* repository home screen.
|
||||
*/
|
||||
function ReposCtrl($scope, $routeParams, repos, users, feed) {
|
||||
function ReposCtrl($scope, $routeParams, repos, users) {
|
||||
|
||||
// Gets the currently authenticated user
|
||||
users.getCached().then(function(payload){
|
||||
|
@ -18,19 +18,6 @@
|
|||
}).catch(function(err){
|
||||
$scope.error = err;
|
||||
});
|
||||
|
||||
// feed.subscribe(function(event) {
|
||||
// if (!$scope.repos) {
|
||||
// return;
|
||||
// }
|
||||
// for (var i=0;i<$scope.repos.length;i++) {
|
||||
// if ($scope.repos[i].full_name === event.repo.full_name) {
|
||||
// $scope.repos[i]=event.repo;
|
||||
// $scope.$apply();
|
||||
// break;
|
||||
// }
|
||||
// };
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -124,9 +124,9 @@
|
|||
}
|
||||
|
||||
|
||||
function RouteChange($rootScope, feed, logs) {
|
||||
function RouteChange($rootScope, repos, logs) {
|
||||
$rootScope.$on('$routeChangeStart', function (event, next) {
|
||||
feed.unsubscribe();
|
||||
repos.unsubscribe();
|
||||
logs.unsubscribe();
|
||||
});
|
||||
|
||||
|
|
|
@ -127,9 +127,12 @@ func GetRepoEvents(c *gin.Context) {
|
|||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-c.Writer.CloseNotify():
|
||||
return
|
||||
case event := <-eventc:
|
||||
if event.Kind == eventbus.EventRepo && event.Name == repo.FullName {
|
||||
if event != nil && event.Kind == eventbus.EventRepo && event.Name == repo.FullName {
|
||||
ws.WriteMessage(websocket.TextMessage, event.Msg)
|
||||
break
|
||||
}
|
||||
case <-ticker.C:
|
||||
ws.SetWriteDeadline(time.Now().Add(writeWait))
|
||||
|
|
Loading…
Reference in a new issue