func (j *Job) SetVersion(ts int64) {
	j.Version.t = time.Unix(ts/1e9, ts%1e9)
}
SetVersion set job version by nano ts
package job
import (
	"errors"
	"fmt"
	"time"
	"github.com/changsongl/delay-queue/pkg/lock"
)
type Job struct {
	Topic   Topic       `json:"topic,omitempty"`
	ID      ID          `json:"id,omitempty"`
	Delay   Delay       `json:"delay,omitempty"`
	TTR     TTR         `json:"ttr,omitempty"`
	Body    Body        `json:"body,omitempty"`
	Version Version     `json:"version,omitempty"`
	Mutex   lock.Locker `json:"-"`
}
func New(topic Topic, id ID, delay Delay, ttr TTR, body Body, lockerFunc lock.LockerFunc) (*Job, error) {
	j := &Job{
		Topic:   topic,
		ID:      id,
		Delay:   delay,
		TTR:     ttr,
		Body:    body,
		Version: NewVersion(),
	}
	err := j.IsValid()
	if err != nil {
		return nil, err
	}
	j.Mutex = lockerFunc(j.getLockName())
	return j, nil
}
func Get(topic Topic, id ID, lockerFunc lock.LockerFunc) (*Job, error) {
	j := &Job{
		Topic: topic,
		ID:    id,
	}
	err := j.IsValid()
	if err != nil {
		return nil, err
	}
	j.Mutex = lockerFunc(j.getLockName())
	return j, nil
}
func (j *Job) IsValid() error {
	if j.Topic == "" || j.ID == "" {
		return errors.New("topic or id is empty")
	}
	return nil
}
func (j *Job) IsVersionSame(v Version) bool {
	return j.Version.Equal(v)
}
func (j *Job) GetName() string {
	return fmt.Sprintf("%s_%s", j.Topic, j.ID)
}
func (j *Job) GetNameWithVersion() NameVersion {
	return NewNameVersion(j.Topic, j.ID, j.Version)
}
func (j *Job) getLockName() string {
	return fmt.Sprintf("%s_lock", j.GetName())
}
func (j *Job) GetDelayTimeFromNow() time.Time {
	return time.Now().Add(time.Duration(j.Delay))
}
func (j *Job) GetTTRTimeFromNow() time.Time {
	return time.Now().Add(time.Duration(j.TTR))
}
func (j *Job) Lock() error {
	return j.Mutex.Lock()
}
func (j *Job) Unlock() (bool, error) {
	return j.Mutex.Unlock()
}