federation

package
v0.0.0-...-46646b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorLocation

type ErrorLocation struct {
	Line   int `json:"line"`
	Column int `json:"column"`
}

ErrorLocation represents the location of an error

type FederatedService

type FederatedService struct {
	Name         string            `json:"name"`
	URL          string            `json:"url"`
	Schema       string            `json:"schema"`
	HealthCheck  string            `json:"healthCheck,omitempty"`
	LastSeen     time.Time         `json:"lastSeen"`
	IsHealthy    bool              `json:"isHealthy"`
	Capabilities map[string]bool   `json:"capabilities"`
	Metadata     map[string]string `json:"metadata"`
}

FederatedService represents a federated GraphQL service

type FederationConfig

type FederationConfig struct {
	GatewayPort         int           `json:"gatewayPort"`
	ServiceTimeout      time.Duration `json:"serviceTimeout"`
	HealthCheckInterval time.Duration `json:"healthCheckInterval"`
	EnableHealthChecks  bool          `json:"enableHealthChecks"`
}

FederationConfig holds configuration for the federation gateway

func DefaultFederationConfig

func DefaultFederationConfig() *FederationConfig

DefaultFederationConfig returns the default federation configuration

type FederationError

type FederationError struct {
	Message    string                 `json:"message"`
	Service    string                 `json:"service,omitempty"`
	Path       []interface{}          `json:"path,omitempty"`
	Extensions map[string]interface{} `json:"extensions,omitempty"`
}

FederationError represents an error from a federated service

type FederationGateway

type FederationGateway struct {
	// contains filtered or unexported fields
}

FederationGateway represents a GraphQL federation gateway

func NewFederationGateway

func NewFederationGateway(logger *slog.Logger) *FederationGateway

NewFederationGateway creates a new GraphQL federation gateway

func (*FederationGateway) ExecuteQuery

func (fg *FederationGateway) ExecuteQuery(ctx context.Context, query string, variables map[string]interface{}) (*FederationResult, error)

ExecuteQuery executes a GraphQL query across federated services

func (*FederationGateway) GetFederatedSchema

func (fg *FederationGateway) GetFederatedSchema() (string, error)

GetFederatedSchema returns the combined schema from all services

func (*FederationGateway) GetHealthyServices

func (fg *FederationGateway) GetHealthyServices() []*FederatedService

GetHealthyServices returns all healthy services

func (*FederationGateway) GetService

func (fg *FederationGateway) GetService(serviceName string) (*FederatedService, bool)

GetService returns a federated service by name

func (*FederationGateway) GetServiceMetrics

func (fg *FederationGateway) GetServiceMetrics() map[string]interface{}

GetServiceMetrics returns metrics for all services

func (*FederationGateway) ListServices

func (fg *FederationGateway) ListServices() []*FederatedService

ListServices returns all registered services

func (*FederationGateway) RegisterService

func (fg *FederationGateway) RegisterService(service *FederatedService) error

RegisterService registers a new federated service

func (*FederationGateway) StartHealthChecks

func (fg *FederationGateway) StartHealthChecks(ctx context.Context, interval time.Duration)

StartHealthChecks starts health checking for all services

func (*FederationGateway) UnregisterService

func (fg *FederationGateway) UnregisterService(serviceName string) error

UnregisterService unregisters a federated service

type FederationResult

type FederationResult struct {
	Data   map[string]interface{} `json:"data"`
	Errors []FederationError      `json:"errors,omitempty"`
}

FederationResult represents the result of a federated GraphQL query

type FederationServer

type FederationServer struct {
	// contains filtered or unexported fields
}

FederationServer represents a GraphQL federation server

func NewFederationServer

func NewFederationServer(gateway *FederationGateway, config *FederationConfig) *FederationServer

NewFederationServer creates a new federation server

func (*FederationServer) CORSMiddleware

func (fs *FederationServer) CORSMiddleware(next http.HandlerFunc) http.HandlerFunc

CORSMiddleware adds CORS headers to responses

func (*FederationServer) GraphQLHandler

func (fs *FederationServer) GraphQLHandler(w http.ResponseWriter, r *http.Request)

GraphQLHandler handles GraphQL requests

func (*FederationServer) HealthHandler

func (fs *FederationServer) HealthHandler(w http.ResponseWriter, r *http.Request)

HealthHandler handles health check requests

func (*FederationServer) MetricsHandler

func (fs *FederationServer) MetricsHandler(w http.ResponseWriter, r *http.Request)

MetricsHandler handles metrics requests

func (*FederationServer) SchemaHandler

func (fs *FederationServer) SchemaHandler(w http.ResponseWriter, r *http.Request)

SchemaHandler returns the federated schema

func (*FederationServer) ServiceHandler

func (fs *FederationServer) ServiceHandler(w http.ResponseWriter, r *http.Request)

ServiceHandler handles individual service requests

func (*FederationServer) ServicesHandler

func (fs *FederationServer) ServicesHandler(w http.ResponseWriter, r *http.Request)

ServicesHandler handles service management requests

func (*FederationServer) Start

func (fs *FederationServer) Start(ctx context.Context) error

Start starts the federation server

type GraphQLError

type GraphQLError struct {
	Message    string                 `json:"message"`
	Locations  []ErrorLocation        `json:"locations,omitempty"`
	Path       []interface{}          `json:"path,omitempty"`
	Extensions map[string]interface{} `json:"extensions,omitempty"`
}

GraphQLError represents a GraphQL error

type GraphQLRequest

type GraphQLRequest struct {
	Query         string                 `json:"query"`
	Variables     map[string]interface{} `json:"variables,omitempty"`
	OperationName string                 `json:"operationName,omitempty"`
}

GraphQLRequest represents a GraphQL request

type GraphQLResponse

type GraphQLResponse struct {
	Data   interface{}    `json:"data,omitempty"`
	Errors []GraphQLError `json:"errors,omitempty"`
}

GraphQLResponse represents a GraphQL response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL