chore(http-timeout): removed timeout functionality when calling the API as it was not needed and malfunctional
This commit is contained in:
parent
a037228b4b
commit
85a7db0d7c
5 changed files with 20 additions and 43 deletions
|
|
@ -53,7 +53,6 @@ func newSDKClient() *edgeconnect.Client {
|
|||
baseURL := viper.GetString("base_url")
|
||||
username := viper.GetString("username")
|
||||
password := viper.GetString("password")
|
||||
createAppInstanceTimeout := viper.GetInt("create_app_instance_timeout")
|
||||
|
||||
err := validateBaseURL(baseURL)
|
||||
if err != nil {
|
||||
|
|
@ -61,20 +60,15 @@ func newSDKClient() *edgeconnect.Client {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Convert timeout from minutes to duration
|
||||
timeout := time.Duration(createAppInstanceTimeout) * time.Minute
|
||||
|
||||
if username != "" && password != "" {
|
||||
return edgeconnect.NewClientWithCredentials(baseURL, username, password,
|
||||
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||
edgeconnect.WithCreateAppInstanceTimeout(timeout),
|
||||
)
|
||||
}
|
||||
|
||||
// Fallback to no auth for now - in production should require auth
|
||||
return edgeconnect.NewClient(baseURL,
|
||||
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||
edgeconnect.WithCreateAppInstanceTimeout(timeout),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
12
cmd/root.go
12
cmd/root.go
|
|
@ -9,11 +9,10 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
cfgFile string
|
||||
baseURL string
|
||||
username string
|
||||
password string
|
||||
createAppInstanceTimeout int // timeout in minutes
|
||||
cfgFile string
|
||||
baseURL string
|
||||
username string
|
||||
password string
|
||||
)
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
|
|
@ -40,12 +39,10 @@ func init() {
|
|||
rootCmd.PersistentFlags().StringVar(&baseURL, "base-url", "", "base URL for the Edge Connect API")
|
||||
rootCmd.PersistentFlags().StringVar(&username, "username", "", "username for authentication")
|
||||
rootCmd.PersistentFlags().StringVar(&password, "password", "", "password for authentication")
|
||||
rootCmd.PersistentFlags().IntVar(&createAppInstanceTimeout, "create-app-instance-timeout", 10, "timeout in minutes for CreateAppInstance operations")
|
||||
|
||||
viper.BindPFlag("base_url", rootCmd.PersistentFlags().Lookup("base-url"))
|
||||
viper.BindPFlag("username", rootCmd.PersistentFlags().Lookup("username"))
|
||||
viper.BindPFlag("password", rootCmd.PersistentFlags().Lookup("password"))
|
||||
viper.BindPFlag("create_app_instance_timeout", rootCmd.PersistentFlags().Lookup("create-app-instance-timeout"))
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
@ -54,7 +51,6 @@ func initConfig() {
|
|||
viper.BindEnv("base_url", "EDGE_CONNECT_BASE_URL")
|
||||
viper.BindEnv("username", "EDGE_CONNECT_USERNAME")
|
||||
viper.BindEnv("password", "EDGE_CONNECT_PASSWORD")
|
||||
viper.BindEnv("create_app_instance_timeout", "EDGE_CONNECT_CREATE_APP_INSTANCE_TIMEOUT")
|
||||
|
||||
if cfgFile != "" {
|
||||
viper.SetConfigFile(cfgFile)
|
||||
|
|
|
|||
|
|
@ -15,14 +15,11 @@ import (
|
|||
// CreateAppInstance creates a new application instance in the specified region
|
||||
// Maps to POST /auth/ctrl/CreateAppInst
|
||||
func (c *Client) CreateAppInstance(ctx context.Context, input *NewAppInstanceInput) error {
|
||||
// Apply CreateAppInstance-specific timeout
|
||||
timeoutCtx, cancel := context.WithTimeout(ctx, c.CreateAppInstanceTimeout)
|
||||
defer cancel()
|
||||
|
||||
transport := c.getTransport()
|
||||
url := c.BaseURL + "/api/v1/auth/ctrl/CreateAppInst"
|
||||
|
||||
resp, err := transport.Call(timeoutCtx, "POST", url, input)
|
||||
resp, err := transport.Call(ctx, "POST", url, input)
|
||||
if err != nil {
|
||||
return fmt.Errorf("CreateAppInstance failed: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,11 @@ import (
|
|||
|
||||
// Client represents the EdgeXR Master Controller SDK client
|
||||
type Client struct {
|
||||
BaseURL string
|
||||
HTTPClient *http.Client
|
||||
AuthProvider AuthProvider
|
||||
RetryOpts RetryOptions
|
||||
Logger Logger
|
||||
CreateAppInstanceTimeout time.Duration
|
||||
BaseURL string
|
||||
HTTPClient *http.Client
|
||||
AuthProvider AuthProvider
|
||||
RetryOpts RetryOptions
|
||||
Logger Logger
|
||||
}
|
||||
|
||||
// RetryOptions configures retry behavior for API calls
|
||||
|
|
@ -82,21 +81,13 @@ func WithLogger(logger Logger) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// WithCreateAppInstanceTimeout sets the timeout for CreateAppInstance operations
|
||||
func WithCreateAppInstanceTimeout(timeout time.Duration) Option {
|
||||
return func(c *Client) {
|
||||
c.CreateAppInstanceTimeout = timeout
|
||||
}
|
||||
}
|
||||
|
||||
// NewClient creates a new EdgeXR SDK client
|
||||
func NewClient(baseURL string, options ...Option) *Client {
|
||||
client := &Client{
|
||||
BaseURL: strings.TrimRight(baseURL, "/"),
|
||||
HTTPClient: &http.Client{Timeout: 30 * time.Second},
|
||||
AuthProvider: NewNoAuthProvider(),
|
||||
RetryOpts: DefaultRetryOptions(),
|
||||
CreateAppInstanceTimeout: 10 * time.Minute,
|
||||
BaseURL: strings.TrimRight(baseURL, "/"),
|
||||
HTTPClient: &http.Client{Timeout: 30 * time.Second},
|
||||
AuthProvider: NewNoAuthProvider(),
|
||||
RetryOpts: DefaultRetryOptions(),
|
||||
}
|
||||
|
||||
for _, opt := range options {
|
||||
|
|
@ -110,11 +101,10 @@ func NewClient(baseURL string, options ...Option) *Client {
|
|||
// This matches the existing client pattern from client/client.go
|
||||
func NewClientWithCredentials(baseURL, username, password string, options ...Option) *Client {
|
||||
client := &Client{
|
||||
BaseURL: strings.TrimRight(baseURL, "/"),
|
||||
HTTPClient: &http.Client{Timeout: 30 * time.Second},
|
||||
AuthProvider: NewUsernamePasswordProvider(baseURL, username, password, nil),
|
||||
RetryOpts: DefaultRetryOptions(),
|
||||
CreateAppInstanceTimeout: 10 * time.Minute,
|
||||
BaseURL: strings.TrimRight(baseURL, "/"),
|
||||
HTTPClient: &http.Client{Timeout: 30 * time.Second},
|
||||
AuthProvider: NewUsernamePasswordProvider(baseURL, username, password, nil),
|
||||
RetryOpts: DefaultRetryOptions(),
|
||||
}
|
||||
|
||||
for _, opt := range options {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# How does it differ from the EdgeXR API?
|
||||
kind: edgeconnect-deployment
|
||||
metadata:
|
||||
name: "edge-app-test" # name could be used for appName
|
||||
name: "edge-app-demo" # name could be used for appName
|
||||
appVersion: "1.0.0"
|
||||
organization: "edp2"
|
||||
spec:
|
||||
|
|
@ -15,7 +15,7 @@ spec:
|
|||
infraTemplate:
|
||||
- region: "EU"
|
||||
cloudletOrg: "TelekomOP"
|
||||
cloudletName: "Hamburg"
|
||||
cloudletName: "Munich"
|
||||
flavorName: "EU.small"
|
||||
network:
|
||||
outboundConnections:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue