1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

temporarily replace bson with gob

This commit is contained in:
Brad Rydzewski 2015-05-05 20:22:02 -07:00
parent fa07d82461
commit cf27863841
5 changed files with 20 additions and 22 deletions

View File

@ -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) {

View File

@ -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];

View File

@ -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;
// }
// };
// });
}
/**

View File

@ -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();
});

View File

@ -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))