summaryrefslogtreecommitdiff
path: root/plugins/jobs/oooold/broker/beanstalk/job.go
blob: fd9c8c3ccc661d8d0bad1f7b62cc8828a9e3590c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package beanstalk

import (
	"bytes"
	"encoding/gob"
	"github.com/spiral/jobs/v2"
)

func pack(j *jobs.Job) ([]byte, error) {
	b := new(bytes.Buffer)
	err := gob.NewEncoder(b).Encode(j)
	if err != nil {
		return nil, err
	}

	return b.Bytes(), nil
}

func unpack(data []byte) (*jobs.Job, error) {
	j := &jobs.Job{}
	err := gob.NewDecoder(bytes.NewBuffer(data)).Decode(j)

	return j, err
}