Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial: update loadbalancer metadata status in resolvers #273

Merged
merged 13 commits into from
Nov 15, 2023
Prev Previous commit
Next Next commit
use helper resolver method
Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com>
rizzza committed Nov 10, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 358608795a2721c4f36bbf7b9a4b4e62a9e4d764
26 changes: 4 additions & 22 deletions internal/graphapi/loadbalancer.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions internal/graphapi/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package graphapi

import (
"context"
"encoding/json"
"fmt"

metadata "go.infratographer.com/metadata-api/pkg/client"
"go.infratographer.com/x/gidx"

"go.infratographer.com/load-balancer-api/internal/config"
)

const metadataStatusSource = "load-balancer-api"

// Metadata interface for the metadata client
type Metadata interface {
StatusUpdate(ctx context.Context, input *metadata.StatusUpdateInput) (*metadata.StatusUpdate, error)
}

// LoadBalancerStatusUpdate updates the state of a load balancer in the metadata service
func (r Resolver) LoadBalancerStatusUpdate(ctx context.Context, loadBalancerID gidx.PrefixedID, state metadata.LoadBalancerState) (*metadata.StatusUpdate, error) {
return r.metadata.StatusUpdate(ctx, &metadata.StatusUpdateInput{
NodeID: loadBalancerID.String(),
NamespaceID: config.AppConfig.Metadata.StatusNamespaceID.String(),
Source: metadataStatusSource,
Data: json.RawMessage(fmt.Sprintf(`{"state": "%s"}`, state)),
})
}
28 changes: 13 additions & 15 deletions internal/graphapi/origin.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 3 additions & 21 deletions internal/graphapi/pool.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 3 additions & 21 deletions internal/graphapi/port.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions internal/graphapi/resolver.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package graphapi

import (
"context"
"fmt"
"net/http"

@@ -11,8 +10,6 @@ import (
"go.infratographer.com/x/gqlgenx/oteltracing"
"go.uber.org/zap"

metadata "go.infratographer.com/metadata-api/pkg/client"

ent "go.infratographer.com/load-balancer-api/internal/ent/generated"
)

@@ -21,18 +18,12 @@ import (
// It serves as dependency injection for your app, add any dependencies you require here.

const (
graphPath = "query"
playgroundPath = "playground"
metadataStatusSource = "load-balancer-api"
graphPath = "query"
playgroundPath = "playground"
)

var graphFullPath = fmt.Sprintf("/%s", graphPath)

// Metadata interface for the metadata client
type Metadata interface {
StatusUpdate(ctx context.Context, input *metadata.StatusUpdateInput) (*metadata.StatusUpdate, error)
}

// Resolver provides a graph response resolver
type Resolver struct {
client *ent.Client