amoghrajesh commented on code in PR #50964:
URL: https://github.com/apache/airflow/pull/50964#discussion_r2104251492


##########
go-sdk/celery/app.go:
##########
@@ -0,0 +1,106 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package celery
+
+import (
+       "context"
+       "encoding/json"
+       "fmt"
+       "log/slog"
+       "os"
+       "os/signal"
+
+       celery "github.com/marselester/gopher-celery"
+       celeryredis "github.com/marselester/gopher-celery/goredis"
+       "github.com/redis/go-redis/v9"
+       "github.com/spf13/viper"
+
+       "github.com/apache/airflow/go-sdk/pkg/api"
+       "github.com/apache/airflow/go-sdk/pkg/sdkcontext"
+       "github.com/apache/airflow/go-sdk/worker"
+)
+
+func Run(ctx context.Context, config Config) error {
+       worker, ok := ctx.Value(sdkcontext.WorkerContextKey).(worker.Worker)
+       if !ok {
+               slog.ErrorContext(ctx, "Worker missing in context")
+               return fmt.Errorf("worker value missing in context")
+       }
+
+       worker, err := worker.WithServer(viper.GetString("execution-api-url"))
+       if err != nil {
+               slog.ErrorContext(ctx, "Error setting ExecutionAPI sxerver for 
worker", "err", err)
+               return err
+       }
+
+       // Store the updated worker in context
+       ctx = context.WithValue(ctx, sdkcontext.WorkerContextKey, worker)
+
+       ctx, stop := signal.NotifyContext(ctx, os.Interrupt)
+       defer stop()
+
+       c := redis.NewClient(&redis.Options{
+               Addr: config.BrokerAddr,
+       })
+       defer func() {
+               if err := c.Close(); err != nil {
+                       slog.ErrorContext(ctx, "failed to close Redis client", 
"err", err)
+               }
+       }()
+
+       if _, err := c.Ping(ctx).Result(); err != nil {
+               slog.ErrorContext(ctx, "Redis connection failed", "err", err)
+               return err
+       }
+       broker := celeryredis.NewBroker(
+               celeryredis.WithClient(c),
+       )
+
+       if len(config.Queues) == 0 {
+               config.Queues = append(config.Queues, "default")
+       }
+       broker.Observe(config.Queues)
+
+       app := celery.NewApp(
+               celery.WithBroker(broker),
+       )
+
+       for _, queue := range config.Queues {
+               app.Register(
+                       "execute_workload",

Review Comment:
   Follow up's fine, all non blocking comments.



##########
go-sdk/celery/cmd/root.go:
##########
@@ -0,0 +1,158 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package cmd
+
+import (
+       "context"
+       "fmt"
+       "os"
+       "path"
+       "strings"
+
+       cc "github.com/ivanpirog/coloredcobra"
+       "github.com/spf13/cobra"
+       "github.com/spf13/pflag"
+       "github.com/spf13/viper"
+
+       "github.com/apache/airflow/go-sdk/pkg/sdkcontext"
+       "github.com/apache/airflow/go-sdk/worker"
+)
+
+var cfgFile string
+
+// rootCmd represents the base command when called without any subcommands
+var rootCmd = &cobra.Command{
+       Use:   "airflow-go-sdk",

Review Comment:
   This one i think is slightly important



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to