jobqueue: rename to worker
This package does not contain an actual queue, but a server and client implementation for osbuild's worker API. Name it accordingly. The queue is in package `store` right now, but about to be split off. This rename makes the `jobqueue` name free for that effort.
This commit is contained in:
parent
76bd5ab984
commit
ac40b0e73b
6 changed files with 15 additions and 15 deletions
|
|
@ -18,10 +18,10 @@ import (
|
||||||
|
|
||||||
"github.com/osbuild/osbuild-composer/internal/common"
|
"github.com/osbuild/osbuild-composer/internal/common"
|
||||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||||
"github.com/osbuild/osbuild-composer/internal/jobqueue"
|
|
||||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||||
"github.com/osbuild/osbuild-composer/internal/store"
|
"github.com/osbuild/osbuild-composer/internal/store"
|
||||||
"github.com/osbuild/osbuild-composer/internal/weldr"
|
"github.com/osbuild/osbuild-composer/internal/weldr"
|
||||||
|
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||||
|
|
||||||
"github.com/coreos/go-systemd/activation"
|
"github.com/coreos/go-systemd/activation"
|
||||||
)
|
)
|
||||||
|
|
@ -117,7 +117,7 @@ func main() {
|
||||||
|
|
||||||
store := store.New(&stateDir)
|
store := store.New(&stateDir)
|
||||||
|
|
||||||
jobAPI := jobqueue.New(logger, store)
|
jobAPI := worker.New(logger, store)
|
||||||
weldrAPI := weldr.New(rpm, arch, distribution, repoMap[common.CurrentArch()], logger, store)
|
weldrAPI := weldr.New(rpm, arch, distribution, repoMap[common.CurrentArch()], logger, store)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ import (
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/osbuild/osbuild-composer/internal/common"
|
"github.com/osbuild/osbuild-composer/internal/common"
|
||||||
"github.com/osbuild/osbuild-composer/internal/jobqueue"
|
|
||||||
"github.com/osbuild/osbuild-composer/internal/target"
|
"github.com/osbuild/osbuild-composer/internal/target"
|
||||||
"github.com/osbuild/osbuild-composer/internal/upload/awsupload"
|
"github.com/osbuild/osbuild-composer/internal/upload/awsupload"
|
||||||
|
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||||
)
|
)
|
||||||
|
|
||||||
type connectionConfig struct {
|
type connectionConfig struct {
|
||||||
|
|
@ -61,7 +61,7 @@ func (e *TargetsError) Error() string {
|
||||||
return errString
|
return errString
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunJob(job *jobqueue.Job, uploadFunc func(*jobqueue.Job, io.Reader) error) (*common.ComposeResult, error) {
|
func RunJob(job *worker.Job, uploadFunc func(*worker.Job, io.Reader) error) (*common.ComposeResult, error) {
|
||||||
tmpStore, err := ioutil.TempDir("/var/tmp", "osbuild-store")
|
tmpStore, err := ioutil.TempDir("/var/tmp", "osbuild-store")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error setting up osbuild store: %v", err)
|
return nil, fmt.Errorf("error setting up osbuild store: %v", err)
|
||||||
|
|
@ -145,9 +145,9 @@ func main() {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
}
|
}
|
||||||
|
|
||||||
var client *jobqueue.Client
|
var client *worker.Client
|
||||||
if unix {
|
if unix {
|
||||||
client = jobqueue.NewClientUnix(address)
|
client = worker.NewClientUnix(address)
|
||||||
} else {
|
} else {
|
||||||
conf, err := createTLSConfig(&connectionConfig{
|
conf, err := createTLSConfig(&connectionConfig{
|
||||||
CACertFile: "/etc/osbuild-composer/ca-crt.pem",
|
CACertFile: "/etc/osbuild-composer/ca-crt.pem",
|
||||||
|
|
@ -158,7 +158,7 @@ func main() {
|
||||||
log.Fatalf("Error creating TLS config: %v", err)
|
log.Fatalf("Error creating TLS config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client = jobqueue.NewClient(address, conf)
|
client = worker.NewClient(address, conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package jobqueue
|
package worker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package jobqueue_test
|
package worker_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -8,9 +8,9 @@ import (
|
||||||
|
|
||||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||||
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
||||||
"github.com/osbuild/osbuild-composer/internal/jobqueue"
|
|
||||||
"github.com/osbuild/osbuild-composer/internal/store"
|
"github.com/osbuild/osbuild-composer/internal/store"
|
||||||
"github.com/osbuild/osbuild-composer/internal/test"
|
"github.com/osbuild/osbuild-composer/internal/test"
|
||||||
|
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestErrors(t *testing.T) {
|
func TestErrors(t *testing.T) {
|
||||||
|
|
@ -35,7 +35,7 @@ func TestErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
api := jobqueue.New(nil, store.New(nil))
|
api := worker.New(nil, store.New(nil))
|
||||||
test.TestRoute(t, api, false, c.Method, c.Path, c.Body, c.ExpectedStatus, "{}", "message")
|
test.TestRoute(t, api, false, c.Method, c.Path, c.Body, c.ExpectedStatus, "{}", "message")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +51,7 @@ func TestCreate(t *testing.T) {
|
||||||
t.Fatalf("error getting image type from arch")
|
t.Fatalf("error getting image type from arch")
|
||||||
}
|
}
|
||||||
store := store.New(nil)
|
store := store.New(nil)
|
||||||
api := jobqueue.New(nil, store)
|
api := worker.New(nil, store)
|
||||||
|
|
||||||
id, err := store.PushCompose(imageType, &blueprint.Blueprint{}, nil, nil, nil, 0, nil)
|
id, err := store.PushCompose(imageType, &blueprint.Blueprint{}, nil, nil, nil, 0, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -73,7 +73,7 @@ func testUpdateTransition(t *testing.T, from, to string, expectedStatus int) {
|
||||||
t.Fatalf("error getting image type from arch")
|
t.Fatalf("error getting image type from arch")
|
||||||
}
|
}
|
||||||
store := store.New(nil)
|
store := store.New(nil)
|
||||||
api := jobqueue.New(nil, store)
|
api := worker.New(nil, store)
|
||||||
|
|
||||||
id := uuid.Nil
|
id := uuid.Nil
|
||||||
if from != "VOID" {
|
if from != "VOID" {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package jobqueue
|
package worker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package jobqueue
|
package worker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue