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

refactor: Move go-sdk to separate repo #1077

Merged
merged 5 commits into from
Nov 18, 2024
Merged

Conversation

CrazyHZM
Copy link
Contributor

@CrazyHZM CrazyHZM commented Nov 7, 2024

Github Action Bot detected the issue body's language is not English, translate it automatically

d the issue body's language is not English, translate it automatically

What this PR does:

see #1075

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Summary by CodeRabbit

Summary byCodeRabbit

  • New Features

    • Introduced a new submodule for the Go SDK to enhance functionality.
  • Bug Fixes

    • Updated import paths for the client package to ensure compatibility with the new SDK location.
  • Chores

    • Removed outdated dependencies and updated the module versioning for improved stability.
    • Deleted obsolete files related to the old SDK implementation to streamline the codebase.
  • Tests

    • Removed tests associated with the deleted SDK components to maintain clarity in testing scope.
原文d the issue body's language is not English, translate it automatically ---

What this PR does:

see #1075

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Summary by CodeRabbit

Summary byCodeRabbit

  • New Features

    • Introduced a new submodule for the Go SDK to enhance functionality.
  • Bug Fixes

    • Updated import paths for the client package to ensure compatibility with the new SDK location.
  • Chores

    • Removed outdated dependencies and updated the module versioning for improved stability.
    • Deleted obsolete files related to the old SDK implementation to streamline the codebase.
  • Tests

    • Removed tests associated with the deleted SDK components to maintain clarity in testing scope.

Copy link

layotto-cla bot commented Nov 7, 2024

Github Action Bot detected the issue body's language is not English, translate it automatically

Hi @CrazyHZM, welcome to mosn community, Please sign Contributor License Agreement!
After you signed CLA, we will automatically sync the status of this pull request in 3 minutes.

原文Hi @CrazyHZM, welcome to mosn community, Please sign Contributor License Agreement!

After you signed CLA, we will automatically sync the status of this pull request in 3 minutes.

Copy link

github-actions bot commented Nov 7, 2024

Hi @CrazyHZM. Thanks for your PR! 🎉
If the PR is ready, use the /cc command to assign reviewer to review.

Details

The full list of commands accepted by this bot can be found here.

The pull request process is described here.

@CrazyHZM CrazyHZM changed the title Move go-sdk to separate repo refactor: Move go-sdk to separate repo Nov 7, 2024
@zhenjunMa zhenjunMa closed this Nov 8, 2024
@zhenjunMa zhenjunMa reopened this Nov 8, 2024
@layotto-cla layotto-cla bot added the cla:yes label Nov 8, 2024
@mingcheng
Copy link
Member

Thank you for your contribution.

I propose that you include a step-by-step guide on how to build in our document.

Signed-off-by: “huazhongming” <[email protected]>
Copy link

coderabbitai bot commented Nov 14, 2024

Github Action Bot detected the issue body's language is not English, translate it automatically

Walkthrough

The pull request introduces significant changes to the project, including the addition of a new submodule sdk/go-sdk and updates to various import paths reflecting a shift from mosn.io/layotto/sdk/go-sdk to github.com/layotto/go-sdk. Several files related to the old SDK have been deleted, including client implementations and associated tests, indicating a transition to a new SDK structure. Additionally, the go.mod file for the old SDK has been removed, along with modifications to the makefiles to streamline testing and dependency management.

Changes

File Path Change Summary
.gitmodules Added submodule sdk/go-sdk with URL [email protected]:layotto/go-sdk.git.
demo/configuration/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/go.mod Removed dependency on mosn.io/layotto/sdk/go-sdk, added github.com/layotto/go-sdk, updated spec version.
demo/hello/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/lock/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/pubsub/client/publish_client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/secret/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/sequencer/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/state/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/state/k8s/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
make/common.mk Removed definition of TEST_RUNTIME_DIR.
make/golang.mk Modified go.unittest and go.format targets to exclude sdk/go-sdk directory.
sdk/go-sdk/client/client.go Deleted file containing gRPC client implementation.
sdk/go-sdk/client/client_generated.go Deleted file containing Client interface and its implementation.
sdk/go-sdk/client/client_test.go Deleted file containing unit tests for the gRPC client.
sdk/go-sdk/client/configuration.go Deleted file related to configuration management.
sdk/go-sdk/client/configuration_test.go Deleted file containing unit tests for configuration management.
sdk/go-sdk/client/goroutine.go Deleted file for managing goroutines with panic recovery.
sdk/go-sdk/client/goroutine_test.go Deleted file containing unit tests for goroutine management.
sdk/go-sdk/client/hello.go Deleted file implementing gRPC client method for saying hello.
sdk/go-sdk/client/hello_test.go Deleted file containing unit tests for the SayHello method.
sdk/go-sdk/client/invoke.go Deleted file for invoking services using gRPC.
sdk/go-sdk/client/invoke_test.go Deleted file containing unit tests for service invocation.
sdk/go-sdk/client/lock.go Deleted file containing locking mechanism methods.
sdk/go-sdk/client/lock_test.go Deleted file containing unit tests for locking mechanism.
sdk/go-sdk/client/pubsub.go Deleted file for publishing events to a pub/sub system.
sdk/go-sdk/client/pubsub_test.go Deleted file containing unit tests for publishing events.
sdk/go-sdk/client/secret.go Deleted file for retrieving secrets via gRPC.
sdk/go-sdk/client/secret_test.go Deleted file containing unit tests for secret retrieval.
sdk/go-sdk/client/sequencer.go Deleted file for retrieving the next ID.
sdk/go-sdk/client/state.go Deleted file for state management client implementation.
sdk/go-sdk/client/state_test.go Deleted file containing unit tests for state management functionality.
sdk/go-sdk/go.mod Removed entire go.mod file for the SDK.
sdk/go-sdk/test/runtime/integrate_test.go Deleted file containing integration tests for various APIs.
sdk/go-sdk/test/runtime/integrate_test.sh Deleted shell script for running integration tests.
sdk/go-sdk/test/runtime/zkCreateZnode.sh Deleted shell script for creating znodes in testing environment.
etc/script/report.sh Removed testing section for the go-sdk from the script.

Poem

🐰 In the meadow, changes bloom,
A new SDK dispels the gloom.
Paths refreshed, imports anew,
With every hop, we leap and pursue.
Goodbye to the old, hello to the bright,
In our code, we find delight! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 347c550 and 6b81982.

📒 Files selected for processing (1)
  • etc/script/report.sh (0 hunks)
💤 Files with no reviewable changes (1)
  • etc/script/report.sh

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fixin commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit. ai/integrations/schema.v2.json

Documentation and Community

原文

Walkthrough

The pull request introduces significant changes to the project, including the addition of a new submodule sdk/go-sdk and updates to various import paths reflecting a shift from mosn.io/layotto/sdk/go-sdk to github.com/layotto/go-sdk. Several files related to the old SDK have been deleted, including client implementations and associated tests, indicating a transition to a new SDK structure. Additionally, the go.mod file for the old SDK has been removed, along with modifications to the makefiles to streamline testing and dependency management.

Changes

File Path Change Summary
.gitmodules Added submodule sdk/go-sdk with URL [email protected]:layotto/go-sdk.git.
demo/configuration/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/go.mod Removed dependency on mosn.io/layotto/sdk/go-sdk, added github.com/layotto/go-sdk, updated spec version.
demo/hello/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/lock/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/pubsub/client/publish_client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/secret/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/sequencer/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/state/common/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
demo/state/k8s/client.go Updated import path from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client.
make/common.mk Removed definition of TEST_RUNTIME_DIR.
make/golang.mk Modified go.unittest and go.format targets to exclude sdk/go-sdk directory.
sdk/go-sdk/client/client.go Deleted file containing gRPC client implementation.
sdk/go-sdk/client/client_generated.go Deleted file containing Client interface and its implementation.
sdk/go-sdk/client/client_test.go Deleted file containing unit tests for the gRPC client.
sdk/go-sdk/client/configuration.go Deleted file related to configuration management.
sdk/go-sdk/client/configuration_test.go Deleted file containing unit tests for configuration management.
sdk/go-sdk/client/goroutine.go Deleted file for managing goroutines with panic recovery.
sdk/go-sdk/client/goroutine_test.go Deleted file containing unit tests for goroutine management.
sdk/go-sdk/client/hello.go Deleted file implementing gRPC client method for saying hello.
sdk/go-sdk/client/hello_test.go Deleted file containing unit tests for the SayHello method.
sdk/go-sdk/client/invoke.go Deleted file for invoking services using gRPC.
sdk/go-sdk/client/invoke_test.go Deleted file containing unit tests for service invocation.
sdk/go-sdk/client/lock.go Deleted file containing locking mechanism methods.
sdk/go-sdk/client/lock_test.go Deleted file containing unit tests for locking mechanism.
sdk/go-sdk/client/pubsub.go Deleted file for publishing events to a pub/sub system.
sdk/go-sdk/client/pubsub_test.go Deleted file containing unit tests for publishing events.
sdk/go-sdk/client/secret.go Deleted file for retrieving secrets via gRPC.
sdk/go-sdk/client/secret_test.go Deleted file containing unit tests for secret retrieval.
sdk/go-sdk/client/sequencer.go Deleted file for retrieving the next ID.
sdk/go-sdk/client/state.go Deleted file for state management client implementation.
sdk/go-sdk/client/state_test.go Deleted file containing unit tests for state management functionality.
sdk/go-sdk/go.mod Removed entire go.mod file for the SDK.
sdk/go-sdk/test/runtime/integrate_test.go Deleted file containing integration tests for various APIs.
sdk/go-sdk/test/runtime/integrate_test.sh Deleted shell script for running integration tests.
sdk/go-sdk/test/runtime/zkCreateZnode.sh Deleted shell script for creating znodes in testing environment.
etc/script/report.sh Removed testing section for the go-sdk from the script.

Poem

🐰 In the meadow, changes bloom,
A new SDK dispels the gloom.
Paths refreshed, imports anew,
With every hop, we leap and pursue.
Goodbye to the old, hello to the bright,
In our code, we find delight! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 347c550 and 6b81982.

📒 Files selected for processing (1)
  • etc/script/report.sh (0 hunks)
💤 Files with no reviewable changes (1)
  • etc/script/report.sh

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (9)
demo/secret/common/client.go (1)

Line range hint 1-54: Add build and usage instructions for the demo.

As requested in the PR comments, please add documentation explaining how to build and run this demo with the new SDK structure. Consider adding:

  • Prerequisites (including how to get the new SDK)
  • Build steps
  • Usage examples with the new SDK

Would you like me to help draft the documentation for this demo?

🧰 Tools
🪛 golangci-lint

8-8: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/sequencer/common/client.go (2)

Line range hint 41-58: Consider improving error handling and documentation

While the code functions correctly, there are some areas for improvement:

  1. The error handling currently uses panic, which isn't ideal for a demo that others might reference
  2. The demo lacks comments explaining the sequencer functionality

Consider these improvements:

 func main() {
 	flag.Parse()
 	if storeName == "" {
-		panic("storeName is empty.")
+		fmt.Println("Error: storeName is required")
+		flag.Usage()
+		os.Exit(1)
 	}
 
+	// Initialize the Layotto client
 	cli, err := client.NewClient()
 	if err != nil {
-		panic(err)
+		fmt.Printf("Failed to create client: %v\n", err)
+		os.Exit(1)
 	}
 	defer cli.Close()
+
+	// Demonstrate getting sequential IDs from the sequencer component
+	// This will generate 10 unique, monotonically increasing IDs
 	ctx := context.Background()
 	fmt.Printf("Try to get next id.Key:%s \n", key)
 	for i := 0; i < 10; i++ {

Line range hint 1-58: Add build and usage instructions

As suggested in the PR comments by mingcheng, the demo should include clear instructions on how to build and run it.

Add a comment block at the top of the file:

 /*
  * Copyright 2021 Layotto Authors
  *
  * Licensed 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.
  */
 
+/*
+ * Sequencer Demo
+ *
+ * This demo shows how to use the Layotto sequencer component to generate
+ * sequential IDs.
+ *
+ * Build:
+ *   go build -o sequencer_demo
+ *
+ * Usage:
+ *   ./sequencer_demo -s <store_name>
+ *
+ * Example:
+ *   ./sequencer_demo -s redis
+ */
+
 package main
demo/lock/common/client.go (2)

Line range hint 1-108: Enhance demo documentation for better user guidance.

Since this is a demo file demonstrating lock functionality with the newly moved SDK, it would be helpful to add:

  1. A package-level comment explaining the demo's purpose
  2. Instructions on how to build and run the demo
  3. Expected output and behavior explanation

Consider adding this documentation at the top of the file:

+// Package main demonstrates the usage of distributed locks using the Layotto Go SDK.
+//
+// To run this demo:
+// 1. Ensure you have Layotto runtime running
+// 2. Build the demo: go build
+// 3. Run: ./client -s <store_name>
+//
+// The demo shows:
+// - How to acquire a lock using TryLock
+// - Lock contention between two clients
+// - Proper unlock procedure
 package main
🧰 Tools
🪛 golangci-lint

11-11: File is not goimports-ed with -local mosn.io/layotto

(goimports)


Line range hint 37-47: Consider improving demo robustness and error handling.

The current implementation has several areas for improvement:

  1. Hardcoded expiry times (1000ms vs 10ms) have a large disparity
  2. Using panic for error handling in a demo might not be ideal

Consider these improvements:

-	resp, err := cli.TryLock(ctx, &runtimev1pb.TryLockRequest{
-		StoreName:  storeName,
-		ResourceId: resourceId,
-		LockOwner:  owner1,
-		Expire:     1000,
-	})
-	if err != nil {
-		panic(err)
-	}
-	if !resp.Success {
-		panic("TryLock failed")
+	const defaultExpiry = 100 // milliseconds
+	resp, err := cli.TryLock(ctx, &runtimev1pb.TryLockRequest{
+		StoreName:  storeName,
+		ResourceId: resourceId,
+		LockOwner:  owner1,
+		Expire:     defaultExpiry,
+	})
+	if err != nil {
+		fmt.Printf("Failed to acquire lock: %v\n", err)
+		return
+	}
+	if !resp.Success {
+		fmt.Println("Could not acquire lock - resource is locked by another client")
+		return

This makes the demo more robust and educational by:

  • Using consistent expiry times
  • Providing informative error messages instead of panics
  • Demonstrating proper error handling patterns

Also applies to: 63-73

🧰 Tools
🪛 golangci-lint

11-11: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/state/k8s/client.go (2)

Line range hint 46-136: Well-structured demo with comprehensive examples.

The code demonstrates good practices:

  • Proper error handling
  • Use of retry mechanisms
  • Clear examples of CRUD operations

Consider these improvements:

 const (
-	key1 = "key1"
-	key2 = "key2"
-	key3 = "key3"
-	key4 = "key4"
-	key5 = "key5"
+	// State management demo keys
+	key1 = "key1"
+	key2 = "key2"
+	key3 = "key3"
+	key4 = "key4"
+	key5 = "key5"
 )

Line range hint 1-24: Enhance documentation for better user guidance.

While the code provides good examples, consider enhancing the documentation to address the feedback about build instructions:

  1. Add a package-level comment explaining this demo's purpose and prerequisites
  2. Include setup instructions (e.g., required environment variables, dependencies)
  3. Add example command-line usage

Example package comment:

 package main

+// This demo showcases state management operations using the Layotto SDK in a Kubernetes environment.
+// It demonstrates CRUD operations with various state management features like ETags and bulk operations.
+//
+// Prerequisites:
+//   - Running Kubernetes cluster
+//   - Layotto runtime configured with a state store
+//
+// Usage:
+//   go run client.go -s <store-name>
demo/configuration/common/client.go (2)

Line range hint 1-199: Documentation enhancement needed

Since this is a demo file showing SDK usage, and given the comment from user mingcheng about build instructions, consider:

  1. Adding more inline documentation about configuration options
  2. Including example output in comments
  3. Adding a link to the full SDK documentation

Would you like me to help draft enhanced documentation for this demo file?

🧰 Tools
🪛 golangci-lint

30-30: File is not goimports-ed with -local mosn.io/layotto

(goimports)


30-30: Fix import ordering

The static analysis tool indicates that the imports are not properly ordered. While this is a minor issue, maintaining consistent import ordering helps with code readability.

import (
	"context"
	"encoding/json"
	"flag"
	"fmt"
	"strconv"
	"sync"
	"time"

	"google.golang.org/grpc"

-	client "github.com/layotto/go-sdk/client"
	runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1"
+	client "github.com/layotto/go-sdk/client"
)
🧰 Tools
🪛 golangci-lint

30-30: File is not goimports-ed with -local mosn.io/layotto

(goimports)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b4fed4d and 816cf28.

⛔ Files ignored due to path filters (2)
  • demo/go.sum is excluded by !**/*.sum
  • sdk/go-sdk/go.sum is excluded by !**/*.sum
📒 Files selected for processing (36)
  • .gitmodules (1 hunks)
  • demo/configuration/common/client.go (1 hunks)
  • demo/go.mod (1 hunks)
  • demo/hello/common/client.go (1 hunks)
  • demo/lock/common/client.go (1 hunks)
  • demo/pubsub/client/publish_client.go (1 hunks)
  • demo/secret/common/client.go (1 hunks)
  • demo/sequencer/common/client.go (1 hunks)
  • demo/state/common/client.go (1 hunks)
  • demo/state/k8s/client.go (1 hunks)
  • make/common.mk (0 hunks)
  • make/golang.mk (0 hunks)
  • sdk/go-sdk/client/client.go (0 hunks)
  • sdk/go-sdk/client/client_generated.go (0 hunks)
  • sdk/go-sdk/client/client_test.go (0 hunks)
  • sdk/go-sdk/client/configuration.go (0 hunks)
  • sdk/go-sdk/client/configuration_test.go (0 hunks)
  • sdk/go-sdk/client/goroutine.go (0 hunks)
  • sdk/go-sdk/client/goroutine_test.go (0 hunks)
  • sdk/go-sdk/client/hello.go (0 hunks)
  • sdk/go-sdk/client/hello_test.go (0 hunks)
  • sdk/go-sdk/client/invoke.go (0 hunks)
  • sdk/go-sdk/client/invoke_test.go (0 hunks)
  • sdk/go-sdk/client/lock.go (0 hunks)
  • sdk/go-sdk/client/lock_test.go (0 hunks)
  • sdk/go-sdk/client/pubsub.go (0 hunks)
  • sdk/go-sdk/client/pubsub_test.go (0 hunks)
  • sdk/go-sdk/client/secret.go (0 hunks)
  • sdk/go-sdk/client/secret_test.go (0 hunks)
  • sdk/go-sdk/client/sequencer.go (0 hunks)
  • sdk/go-sdk/client/state.go (0 hunks)
  • sdk/go-sdk/client/state_test.go (0 hunks)
  • sdk/go-sdk/go.mod (0 hunks)
  • sdk/go-sdk/test/runtime/integrate_test.go (0 hunks)
  • sdk/go-sdk/test/runtime/integrate_test.sh (0 hunks)
  • sdk/go-sdk/test/runtime/zkCreateZnode.sh (0 hunks)
💤 Files with no reviewable changes (26)
  • make/common.mk
  • make/golang.mk
  • sdk/go-sdk/client/client.go
  • sdk/go-sdk/client/client_generated.go
  • sdk/go-sdk/client/client_test.go
  • sdk/go-sdk/client/configuration.go
  • sdk/go-sdk/client/configuration_test.go
  • sdk/go-sdk/client/goroutine.go
  • sdk/go-sdk/client/goroutine_test.go
  • sdk/go-sdk/client/hello.go
  • sdk/go-sdk/client/hello_test.go
  • sdk/go-sdk/client/invoke.go
  • sdk/go-sdk/client/invoke_test.go
  • sdk/go-sdk/client/lock.go
  • sdk/go-sdk/client/lock_test.go
  • sdk/go-sdk/client/pubsub.go
  • sdk/go-sdk/client/pubsub_test.go
  • sdk/go-sdk/client/secret.go
  • sdk/go-sdk/client/secret_test.go
  • sdk/go-sdk/client/sequencer.go
  • sdk/go-sdk/client/state.go
  • sdk/go-sdk/client/state_test.go
  • sdk/go-sdk/go.mod
  • sdk/go-sdk/test/runtime/integrate_test.go
  • sdk/go-sdk/test/runtime/integrate_test.sh
  • sdk/go-sdk/test/runtime/zkCreateZnode.sh
✅ Files skipped from review due to trivial changes (4)
  • .gitmodules
  • demo/hello/common/client.go
  • demo/pubsub/client/publish_client.go
  • demo/state/common/client.go
🧰 Additional context used
🪛 golangci-lint
demo/configuration/common/client.go

30-30: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/lock/common/client.go

11-11: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/secret/common/client.go

8-8: File is not goimports-ed with -local mosn.io/layotto

(goimports)

🔇 Additional comments (5)
demo/secret/common/client.go (1)

8-8: Verify the new SDK import path is accessible and stable.

The import path change aligns with moving the SDK to a separate repository. However, we should ensure the new import path is stable and accessible for users.

#!/bin/bash
# Description: Verify the new SDK repository and its accessibility

# Check if the new SDK repository exists and is public
gh repo view github.com/layotto/go-sdk --json name,visibility,isArchived

# Check if there are any other references to the old SDK path that need updating
rg "mosn.io/layotto/sdk/go-sdk" --type go
🧰 Tools
🪛 golangci-lint

8-8: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/go.mod (2)

26-26: Verify the stability of the new SDK dependency

The new SDK dependency is using a pseudo-version (v0.0.0-20241113124402-e55ee5816d2f). Consider:

  1. Using a stable tagged version if available
  2. Ensuring this version matches the submodule reference

27-27: Verify spec compatibility with demo applications

The spec dependency has been updated to a newer version. Ensure this change doesn't introduce breaking changes that could affect the demo applications.

demo/lock/common/client.go (1)

11-11: Verify the new SDK import path and fix import ordering.

The import path has been updated to reflect the SDK's new location. Let's ensure everything is in order:

Consider running goimports to fix the import ordering:

import (
	"context"
	"flag"
	"fmt"
	"sync"

	"github.com/google/uuid"
-	client "github.com/layotto/go-sdk/client"
	runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1"
+	client "github.com/layotto/go-sdk/client"
)
✅ Verification successful

Import path change is valid and consistent across the codebase

Based on the verification results:

  1. The old import path mosn.io/layotto/sdk/go-sdk is no longer present in the codebase
  2. The new import path github.com/layotto/go-sdk is consistently used across multiple demo files:
    • demo/lock/common/client.go
    • demo/sequencer/common/client.go
    • demo/secret/common/client.go
    • demo/pubsub/client/publish_client.go
    • demo/hello/common/client.go
    • demo/state/common/client.go
    • demo/configuration/common/client.go
    • demo/state/k8s/client.go

The import path change is correctly implemented and consistent throughout the codebase. The goimports ordering suggestion remains valid but is a minor stylistic issue.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the new SDK repository and its accessibility

# Check if the new SDK repo exists and is accessible
gh repo view github.com/layotto/go-sdk

# Verify if other files still reference the old import path
rg "mosn.io/layotto/sdk/go-sdk/client" --type go

# Check go.mod for proper version constraint
rg "github.com/layotto/go-sdk" go.mod

Length of output: 220


Script:

#!/bin/bash
# Let's verify the import changes more thoroughly

# Check all Go files for any remaining old SDK imports
rg "mosn.io/layotto/sdk/go-sdk" --type go

# Check go.mod content to understand dependencies
cat go.mod

# Check if there are any other files that need similar import updates
fd -e go -x grep -l "github.com/layotto/go-sdk"

# Look for any potential build or dependency instructions in README
cat README.md | grep -A 5 -i "build\|dependency\|install"

Length of output: 18624

🧰 Tools
🪛 golangci-lint

11-11: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/configuration/common/client.go (1)

30-30: Verify the new SDK package availability

The import path has been updated to use the new SDK location. Please ensure:

  1. The new SDK repository is publicly available
  2. The version being used is stable and tagged
  3. The migration guide is documented for existing users

Consider adding a deprecation notice in the old SDK location to guide users to the new package.

🧰 Tools
🪛 golangci-lint

30-30: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/secret/common/client.go Outdated Show resolved Hide resolved
demo/state/k8s/client.go Show resolved Hide resolved
.gitmodules Outdated Show resolved Hide resolved
Signed-off-by: “huazhongming” <[email protected]>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (10)
demo/pubsub/client/publish_client.go (1)

Line range hint 33-57: Consider improving error handling in the demo.

While this is a demo, using panic for error handling might not set the best example for users. Consider:

  1. Using proper error handling with logging
  2. Adding graceful shutdown
  3. Adding comments explaining the expected behavior

Here's a suggested improvement:

 func main() {
 	flag.Parse()
 	if storeName == "" {
-		panic("storeName is empty.")
+		fmt.Println("Error: storeName is required")
+		flag.Usage()
+		os.Exit(1)
 	}
 	// 1. construct client
 	cli, err := client.NewClient()
 	if err != nil {
-		panic(err)
+		fmt.Printf("Failed to create client: %v\n", err)
+		os.Exit(1)
 	}
+	defer cli.Close()
+
+	// 2. publish example events
+	// The events will be delivered to subscribers of these topics
 	testPublish(cli, "hello", "world")
 	testPublish(cli, "topic1", "value1")
-	cli.Close()
 }

 func testPublish(cli client.Client, topic string, value string) error {
 	data := []byte(value)
 	err := cli.PublishEvent(context.Background(), storeName, topic, data)
 	if err != nil {
-		panic(err)
+		fmt.Printf("Failed to publish event to topic %s: %v\n", topic, err)
+		return err
 	}
 	fmt.Printf("Published a new event.Topic: %s ,Data: %s \n", topic, data)
 	return err
 }
demo/lock/common/client.go (3)

11-12: Fix import ordering

The imports need to be ordered according to the Go standards: standard library, external packages, then internal packages.

import (
	"context"
	"flag"
	"fmt"
	"sync"

	"github.com/google/uuid"
-	client "github.com/layotto/go-sdk/client"
-	runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1"
+	runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1"
+	client "github.com/layotto/go-sdk/client"
)
🧰 Tools
🪛 golangci-lint

11-11: File is not goimports-ed with -local mosn.io/layotto

(goimports)


Line range hint 1-124: Improve demo code quality and documentation

While the code demonstrates the lock functionality, there are several areas for improvement to make it a better example:

  1. Replace panic with proper error handling
  2. Add comments explaining the distributed locking concepts
  3. Make timeout values configurable via flags
  4. Add cleanup in case of errors

Would you like me to propose a refactored version that addresses these points?

🧰 Tools
🪛 golangci-lint

11-11: File is not goimports-ed with -local mosn.io/layotto

(goimports)


Line range hint 14-16: Consider making constants configurable

The resourceId constant is hardcoded. Consider making it configurable via flags, similar to storeName, to make the demo more flexible.

🧰 Tools
🪛 golangci-lint

11-11: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/state/common/client.go (2)

Line range hint 46-48: Consider improving error handling patterns

While this is a demo file, consider replacing panic with proper error handling to demonstrate best practices. This would make the demo more production-ready and educational.

Example improvement:

func testSave(ctx context.Context, cli client.Client, store string, key string, value []byte) {
-	if err := cli.SaveState(ctx, store, key, value); err != nil {
-		panic(err)
-	}
+	if err := cli.SaveState(ctx, store, key, value); err != nil {
+		fmt.Printf("Failed to save state: %v\n", err)
+		return
+	}
	fmt.Printf("SaveState succeeded.key:%v , value: %v \n", key, string(value))
}

Also applies to: 89-91, 106-108, 122-124, 134-136


Line range hint 1-143: Enhance demo documentation for better user guidance

Since this is a demo file and there's a request for better documentation, consider:

  1. Adding detailed comments explaining each state management operation
  2. Including example output in comments
  3. Adding error scenarios and how to handle them
  4. Documenting the required configuration for the state store

Example improvement for the main function:

 func main() {
+	// This demo shows how to use Layotto's state management API
+	// It demonstrates the following operations:
+	// 1. Saving individual state
+	// 2. Retrieving state
+	// 3. Bulk state operations
+	// 4. State deletion with ETags for concurrency control
+	//
+	// Required configuration:
+	// - A running Layotto instance
+	// - Configured state store component (e.g., Redis)
+	// 
+	// Usage:
+	// go run client.go -s my-state-store
+
 	// parse command arguments
 	flag.Parse()
demo/state/k8s/client.go (1)

Line range hint 1-168: Consider restructuring the demo code for better maintainability.

While the implementation is functionally correct, consider the following architectural improvements:

  1. Extract the test scenarios into separate example files (e.g., examples/state/basic/main.go, examples/state/bulk/main.go).
  2. Add proper logging instead of fmt.Printf for better observability.
  3. Consider using a configuration file for store settings instead of command-line flags.
demo/configuration/common/client.go (3)

Line range hint 63-76: Add documentation for eventual consistency behavior

The code includes sleep statements to handle eventual consistency, but this behavior should be documented to help users understand the timing requirements.

Consider adding a comment explaining the eventual consistency model:

 	// 2. get after set
-	// Since configuration data might be cached and eventual-consistent,we need to sleep a while before querying new data
+	// Wait for eventual consistency. The configuration service uses a cached, eventually-consistent
+	// model where changes may take a few seconds to propagate to all nodes.
 	time.Sleep(time.Second * 2)
 	testGet(ctx, cli)
🧰 Tools
🪛 golangci-lint

30-30: File is not goimports-ed with -local mosn.io/layotto

(goimports)


Line range hint 95-112: Improve error handling in subscription handler

The subscription handler could benefit from more robust error handling and graceful shutdown.

Consider this improved implementation:

 	go func() {
 		for resp := range ch {
 			if resp.Err != nil {
-				panic(resp.Err)
+				fmt.Printf("Error in subscription: %v\n", resp.Err)
+				continue
 			}
 			marshal, err := json.Marshal(resp.Item)
 			if err != nil {
-				fmt.Println("marshal resp.Item failed.")
-				return
+				fmt.Printf("Failed to marshal response item: %v\n", err)
+				continue
 			}
 			fmt.Printf("receive subscribe resp: %+v\n", string(marshal))
 		}
 		fmt.Println("subscribe channel has been closed.")
 	}()
🧰 Tools
🪛 golangci-lint

30-30: File is not goimports-ed with -local mosn.io/layotto

(goimports)


Line range hint 17-17: Add package documentation and usage examples

The file would benefit from comprehensive package documentation that includes:

  1. Purpose and usage of the configuration client
  2. Examples of different configuration operations
  3. Build and setup instructions as requested in PR comments

Add package documentation at the start of the file:

 package main

+// Package main demonstrates the usage of Layotto configuration API with both SDK and gRPC clients.
+//
+// This demo shows how to:
+// - Set and retrieve configuration items
+// - Delete configuration entries
+// - Subscribe to configuration changes
+//
+// Build and run instructions:
+// 1. Install dependencies: go mod download
+// 2. Build the demo: go build
+// 3. Run with SDK mode: ./client -s <storeName> -mode sdk
+// 4. Run with gRPC mode: ./client -s <storeName> -mode raw
🧰 Tools
🪛 golangci-lint

30-30: File is not goimports-ed with -local mosn.io/layotto

(goimports)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b4fed4d and 83add0d.

⛔ Files ignored due to path filters (2)
  • demo/go.sum is excluded by !**/*.sum
  • sdk/go-sdk/go.sum is excluded by !**/*.sum
📒 Files selected for processing (35)
  • demo/configuration/common/client.go (1 hunks)
  • demo/go.mod (1 hunks)
  • demo/hello/common/client.go (1 hunks)
  • demo/lock/common/client.go (1 hunks)
  • demo/pubsub/client/publish_client.go (1 hunks)
  • demo/secret/common/client.go (1 hunks)
  • demo/sequencer/common/client.go (1 hunks)
  • demo/state/common/client.go (1 hunks)
  • demo/state/k8s/client.go (1 hunks)
  • make/common.mk (0 hunks)
  • make/golang.mk (0 hunks)
  • sdk/go-sdk/client/client.go (0 hunks)
  • sdk/go-sdk/client/client_generated.go (0 hunks)
  • sdk/go-sdk/client/client_test.go (0 hunks)
  • sdk/go-sdk/client/configuration.go (0 hunks)
  • sdk/go-sdk/client/configuration_test.go (0 hunks)
  • sdk/go-sdk/client/goroutine.go (0 hunks)
  • sdk/go-sdk/client/goroutine_test.go (0 hunks)
  • sdk/go-sdk/client/hello.go (0 hunks)
  • sdk/go-sdk/client/hello_test.go (0 hunks)
  • sdk/go-sdk/client/invoke.go (0 hunks)
  • sdk/go-sdk/client/invoke_test.go (0 hunks)
  • sdk/go-sdk/client/lock.go (0 hunks)
  • sdk/go-sdk/client/lock_test.go (0 hunks)
  • sdk/go-sdk/client/pubsub.go (0 hunks)
  • sdk/go-sdk/client/pubsub_test.go (0 hunks)
  • sdk/go-sdk/client/secret.go (0 hunks)
  • sdk/go-sdk/client/secret_test.go (0 hunks)
  • sdk/go-sdk/client/sequencer.go (0 hunks)
  • sdk/go-sdk/client/state.go (0 hunks)
  • sdk/go-sdk/client/state_test.go (0 hunks)
  • sdk/go-sdk/go.mod (0 hunks)
  • sdk/go-sdk/test/runtime/integrate_test.go (0 hunks)
  • sdk/go-sdk/test/runtime/integrate_test.sh (0 hunks)
  • sdk/go-sdk/test/runtime/zkCreateZnode.sh (0 hunks)
💤 Files with no reviewable changes (26)
  • make/common.mk
  • make/golang.mk
  • sdk/go-sdk/client/client.go
  • sdk/go-sdk/client/client_generated.go
  • sdk/go-sdk/client/client_test.go
  • sdk/go-sdk/client/configuration.go
  • sdk/go-sdk/client/configuration_test.go
  • sdk/go-sdk/client/goroutine.go
  • sdk/go-sdk/client/goroutine_test.go
  • sdk/go-sdk/client/hello.go
  • sdk/go-sdk/client/hello_test.go
  • sdk/go-sdk/client/invoke.go
  • sdk/go-sdk/client/invoke_test.go
  • sdk/go-sdk/client/lock.go
  • sdk/go-sdk/client/lock_test.go
  • sdk/go-sdk/client/pubsub.go
  • sdk/go-sdk/client/pubsub_test.go
  • sdk/go-sdk/client/secret.go
  • sdk/go-sdk/client/secret_test.go
  • sdk/go-sdk/client/sequencer.go
  • sdk/go-sdk/client/state.go
  • sdk/go-sdk/client/state_test.go
  • sdk/go-sdk/go.mod
  • sdk/go-sdk/test/runtime/integrate_test.go
  • sdk/go-sdk/test/runtime/integrate_test.sh
  • sdk/go-sdk/test/runtime/zkCreateZnode.sh
✅ Files skipped from review due to trivial changes (2)
  • demo/hello/common/client.go
  • demo/secret/common/client.go
🧰 Additional context used
🪛 golangci-lint
demo/configuration/common/client.go

30-30: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/lock/common/client.go

11-11: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/sequencer/common/client.go

24-24: File is not goimports-ed with -local mosn.io/layotto

(goimports)

🔇 Additional comments (5)
demo/go.mod (1)

26-27: Verify dependency compatibility

The changes to both dependencies (go-sdk and spec) are significant. Please ensure:

  1. The new go-sdk version is compatible with the updated spec version
  2. All demo code works correctly with these versions

Let's check for potential version mismatches:

#!/bin/bash
# Description: Check if go-sdk and spec versions are aligned
# Expected: Find any version-specific imports or type usage

# Check for spec types usage in demo code
rg --type go "mosn.io/layotto/spec/\w+/v\d+" demo/

# Check for potential version conflicts in go.sum
if [ -f demo/go.sum ]; then
  grep -E "github.com/layotto/go-sdk|mosn.io/layotto/spec" demo/go.sum
fi
demo/pubsub/client/publish_client.go (1)

24-24: LGTM! Verify SDK availability.

The import path change aligns with moving the SDK to a separate repository.

Let's verify the SDK availability and consistent usage across demos:

✅ Verification successful

Based on the results, I can generate the final response as we have sufficient information:

Import path change verified and SDK is publicly accessible

The verification confirms:

  • No remaining old SDK imports (mosn.io/layotto/sdk/go-sdk/client) found in the demo directory
  • The new SDK repository (layotto/go-sdk) is publicly available
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify SDK availability and consistent usage

# Check if the new SDK import is used consistently across all demo files
echo "Checking for any remaining old SDK imports..."
rg -l "mosn.io/layotto/sdk/go-sdk/client" "demo/"

# Check if the new SDK is publicly available
echo "Checking SDK availability..."
gh api repos/layotto/go-sdk -q '.visibility'

Length of output: 267

demo/lock/common/client.go (1)

11-11: Verify the new SDK repository accessibility

The import path has been updated to use the new SDK location. Let's verify its accessibility.

✅ Verification successful

Import path change is valid and accessible

The new SDK repository at github.com/layotto/go-sdk is:

  • Publicly accessible
  • Not archived
  • Contains the required client package at client/client.go
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the new SDK repository exists and is public
gh repo view github.com/layotto/go-sdk --json name,visibility,isArchived,defaultBranchRef

# Verify go.mod in the new SDK repo contains the client package
gh api repos/layotto/go-sdk/contents/client/client.go --jq .name

Length of output: 262

🧰 Tools
🪛 golangci-lint

11-11: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/state/k8s/client.go (1)

28-28: LGTM! Import path updated as part of SDK migration.

The import path change aligns with the PR objective of moving the go-sdk to a separate repository.

demo/configuration/common/client.go (1)

30-30: Verify the new import path usage across the codebase

The import path change from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client aligns with moving the SDK to a separate repository.

Let's verify the consistency of this change across the codebase:

✅ Verification successful

Import path migration is complete and consistent

The verification shows that all imports of the client package have been updated to use the new path github.com/layotto/go-sdk/client. No instances of the old import path mosn.io/layotto/sdk/go-sdk/client were found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining old import paths
rg "mosn\.io/layotto/sdk/go-sdk/client" --type go

# Search for new import paths to ensure consistent adoption
rg "github\.com/layotto/go-sdk/client" --type go

Length of output: 674

🧰 Tools
🪛 golangci-lint

30-30: File is not goimports-ed with -local mosn.io/layotto

(goimports)

demo/go.mod Show resolved Hide resolved
zhenjunMa
zhenjunMa previously approved these changes Nov 18, 2024
Signed-off-by: “huazhongming” <[email protected]>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
demo/configuration/common/client.go (2)

Line range hint 58-62: Consider improving error handling patterns.

  1. The initialization error handling currently uses panic, which might not be ideal for a demo as it doesn't showcase proper error handling patterns.
  2. The subscription error handling could benefit from a more robust recovery mechanism.

Consider these improvements:

 // create a layotto client
 cli, err := client.NewClient()
 if err != nil {
-    panic(err)
+    fmt.Printf("Failed to create client: %v\n", err)
+    os.Exit(1)
 }

 // In subscription handler
 go func() {
     for resp := range ch {
         if resp.Err != nil {
-            panic(resp.Err)
+            fmt.Printf("Subscription error: %v\n", resp.Err)
+            // Implement retry logic or graceful error recovery
+            continue
         }
         // ... rest of the code
     }
 }()

Also applies to: 95-99


Line range hint 1-24: Enhance documentation for better developer experience.

While the examples are comprehensive, consider these documentation improvements:

  1. Add a package-level comment explaining the purpose of these examples
  2. Include example output in comments
  3. Add links to the new SDK repository and documentation

This aligns with the PR feedback requesting better build instructions.

Example package documentation:

/*
Package main demonstrates the usage of Layotto configuration management features.

This example showcases:
- Basic CRUD operations for configurations
- Configuration subscription using both SDK and gRPC
- Error handling patterns

Example usage:
    go run client.go -s redis -mode sdk

For more examples and documentation, visit:
https://github.com/layotto/go-sdk
*/
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b4fed4d and 02ae59f.

⛔ Files ignored due to path filters (4)
  • demo/go.sum is excluded by !**/*.sum
  • sdk/go-sdk/go.sum is excluded by !**/*.sum
  • spec/proto/extension/v1/s3/oss.pb.go is excluded by !**/*.pb.go
  • spec/proto/extension/v1/s3/oss_grpc.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (41)
  • components/pluggable/grpc_mock.go (0 hunks)
  • components/sequencer/snowflake/snowflake.go (1 hunks)
  • components/sequencer/snowflake/snowflake_sequencer.go (0 hunks)
  • components/sequencer/snowflake/snowflake_sequencer_test.go (0 hunks)
  • components/sequencer/snowflake/snowflake_test.go (0 hunks)
  • demo/configuration/common/client.go (1 hunks)
  • demo/go.mod (1 hunks)
  • demo/hello/common/client.go (1 hunks)
  • demo/lock/common/client.go (1 hunks)
  • demo/pubsub/client/publish_client.go (1 hunks)
  • demo/secret/common/client.go (1 hunks)
  • demo/sequencer/common/client.go (1 hunks)
  • demo/state/common/client.go (1 hunks)
  • demo/state/k8s/client.go (1 hunks)
  • make/common.mk (0 hunks)
  • make/golang.mk (0 hunks)
  • pkg/mock/components/lock/lock.go (1 hunks)
  • sdk/go-sdk/client/client.go (0 hunks)
  • sdk/go-sdk/client/client_generated.go (0 hunks)
  • sdk/go-sdk/client/client_test.go (0 hunks)
  • sdk/go-sdk/client/configuration.go (0 hunks)
  • sdk/go-sdk/client/configuration_test.go (0 hunks)
  • sdk/go-sdk/client/goroutine.go (0 hunks)
  • sdk/go-sdk/client/goroutine_test.go (0 hunks)
  • sdk/go-sdk/client/hello.go (0 hunks)
  • sdk/go-sdk/client/hello_test.go (0 hunks)
  • sdk/go-sdk/client/invoke.go (0 hunks)
  • sdk/go-sdk/client/invoke_test.go (0 hunks)
  • sdk/go-sdk/client/lock.go (0 hunks)
  • sdk/go-sdk/client/lock_test.go (0 hunks)
  • sdk/go-sdk/client/pubsub.go (0 hunks)
  • sdk/go-sdk/client/pubsub_test.go (0 hunks)
  • sdk/go-sdk/client/secret.go (0 hunks)
  • sdk/go-sdk/client/secret_test.go (0 hunks)
  • sdk/go-sdk/client/sequencer.go (0 hunks)
  • sdk/go-sdk/client/state.go (0 hunks)
  • sdk/go-sdk/client/state_test.go (0 hunks)
  • sdk/go-sdk/go.mod (0 hunks)
  • sdk/go-sdk/test/runtime/integrate_test.go (0 hunks)
  • sdk/go-sdk/test/runtime/integrate_test.sh (0 hunks)
  • sdk/go-sdk/test/runtime/zkCreateZnode.sh (0 hunks)
💤 Files with no reviewable changes (30)
  • components/pluggable/grpc_mock.go
  • components/sequencer/snowflake/snowflake_sequencer.go
  • components/sequencer/snowflake/snowflake_sequencer_test.go
  • components/sequencer/snowflake/snowflake_test.go
  • make/common.mk
  • make/golang.mk
  • sdk/go-sdk/client/client.go
  • sdk/go-sdk/client/client_generated.go
  • sdk/go-sdk/client/client_test.go
  • sdk/go-sdk/client/configuration.go
  • sdk/go-sdk/client/configuration_test.go
  • sdk/go-sdk/client/goroutine.go
  • sdk/go-sdk/client/goroutine_test.go
  • sdk/go-sdk/client/hello.go
  • sdk/go-sdk/client/hello_test.go
  • sdk/go-sdk/client/invoke.go
  • sdk/go-sdk/client/invoke_test.go
  • sdk/go-sdk/client/lock.go
  • sdk/go-sdk/client/lock_test.go
  • sdk/go-sdk/client/pubsub.go
  • sdk/go-sdk/client/pubsub_test.go
  • sdk/go-sdk/client/secret.go
  • sdk/go-sdk/client/secret_test.go
  • sdk/go-sdk/client/sequencer.go
  • sdk/go-sdk/client/state.go
  • sdk/go-sdk/client/state_test.go
  • sdk/go-sdk/go.mod
  • sdk/go-sdk/test/runtime/integrate_test.go
  • sdk/go-sdk/test/runtime/integrate_test.sh
  • sdk/go-sdk/test/runtime/zkCreateZnode.sh
✅ Files skipped from review due to trivial changes (6)
  • components/sequencer/snowflake/snowflake.go
  • demo/hello/common/client.go
  • demo/lock/common/client.go
  • demo/pubsub/client/publish_client.go
  • demo/secret/common/client.go
  • demo/state/k8s/client.go
🔇 Additional comments (7)
demo/go.mod (2)

26-26: Skip comment about indirect marker


26-27: Verify version compatibility between SDK and spec

The SDK and spec versions are both using pre-release versions (0.0.0). Let's verify their compatibility and check for any potential breaking changes.

✅ Verification successful

Let me gather more information about the specific versions and their compatibility.


Let me check one more aspect to verify the API compatibility between these versions.


SDK and spec versions are compatible

Based on the verification:

  1. Both versions are recent commits (SDK: e55ee5816d2f from Nov 2024, Spec: b4fed4d from Sept 2024)
  2. The SDK commit is a CI fix, not introducing breaking changes
  3. The spec commit adds Aliyun OSS support, which is a feature addition
  4. All imports consistently use v1 proto definitions (runtime/v1 and extension/v1)
  5. No compatibility issues are evident in the proto usage patterns
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check version compatibility between SDK and spec
# Expected: Find any version constraints or compatibility requirements

# Check go.mod in SDK repo for its spec dependency
gh api repos/layotto/go-sdk/contents/go.mod | jq -r '.content' | base64 -d | grep "mosn.io/layotto/spec"

# Check imports to identify potential compatibility issues
rg --type go "mosn.io/layotto/spec" demo/

Length of output: 1941


Script:

#!/bin/bash
# Check the specific commit of SDK being used
git ls-remote https://github.com/layotto/go-sdk.git e55ee5816d2f

# Check the specific commit of spec being used
git ls-remote https://github.com/mosn/layotto.git b4fed4d06be4

# Check changelog or commit messages for these specific versions
gh api repos/layotto/go-sdk/commits/e55ee5816d2f | jq -r '.commit.message'
gh api repos/mosn/layotto/commits/b4fed4d06be4 | jq -r '.commit.message'

Length of output: 694


Script:

#!/bin/bash
# Check the proto files in both versions to verify API compatibility
# First, check the proto imports in the demo code
rg -g "*.proto" "package" demo/

# Then check what proto versions are being used in the imports we found earlier
rg -g "*.go" "proto/runtime/v1|proto/extension/v1" demo/ -B1 -A1

Length of output: 3025

demo/sequencer/common/client.go (1)

24-24: LGTM! Import path updated correctly.

The import path has been updated to use the new SDK location, which aligns with moving the SDK to a separate repository.

pkg/mock/components/lock/lock.go (2)

Line range hint 1-110: Generated code - no review needed

This is an auto-generated mock file using GoMock. No review needed for the implementation.


12-12: Verify if the import path needs updating

Given that this PR moves the SDK to a separate repo and updates import paths from mosn.io/layotto/sdk/go-sdk to github.com/layotto/go-sdk, please verify if this import path should also be updated:

import lock "mosn.io/layotto/components/lock"
demo/configuration/common/client.go (2)

Line range hint 58-62: Clean refactoring with maintained API compatibility.

The client usage remains unchanged after the import path update, indicating good backward compatibility maintenance in the SDK migration.


30-31: Verify the new SDK import path accessibility and version.

The import path change aligns with moving the SDK to a separate repository.

✅ Verification successful

Import path change is consistent and properly implemented

The verification shows that:

  1. The new import path github.com/layotto/go-sdk/client is used in the configuration demo.
  2. The client package is used extensively throughout the configuration demo for various operations (Subscribe, Save, Get, Delete).
  3. No instances of the old import path mosn.io/layotto/sdk/go-sdk/client were found in the demo directory.
  4. The go.mod file shows proper module management, though the new SDK dependency is not yet visible (likely part of this PR's changes).
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the new SDK import path and its consistent usage

# Check if the new import path is consistently used across all demo files
echo "Checking for any remaining old import paths..."
rg -l "mosn.io/layotto/sdk/go-sdk/client" "demo/"

# Check if the new module is properly versioned in go.mod
echo "Checking go.mod for the new SDK..."
rg "github.com/layotto/go-sdk" "go.mod"

Length of output: 267


Script:

#!/bin/bash
# Let's try a more comprehensive verification approach

# 1. Check all Go imports in demo directory
echo "=== Checking all imports in demo directory ==="
rg -A 1 "^import \(" demo/ || rg "^import .*client" demo/

# 2. Check if go.mod exists and its content
echo -e "\n=== Checking go.mod content ==="
if [ -f "go.mod" ]; then
    cat go.mod
else
    echo "go.mod not found"
fi

# 3. Check all files in demo/configuration for client usage
echo -e "\n=== Checking client usage in configuration demos ==="
rg "client\." demo/configuration/

# 4. List all Go files in demo/configuration to ensure we're not missing anything
echo -e "\n=== Listing Go files in demo/configuration ==="
fd -e go . demo/configuration/

Length of output: 22345

demo/sequencer/common/client.go Show resolved Hide resolved
demo/state/common/client.go Show resolved Hide resolved
Signed-off-by: “huazhongming” <[email protected]>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
demo/state/k8s/go.mod (1)

5-5: Consider updating retry-go to a semantically versioned release

The current version v3.0.0+incompatible indicates this module doesn't follow semantic versioning. Consider updating to a newer version that follows semver to ensure better compatibility and dependency management.

-require github.com/avast/retry-go v3.0.0+incompatible
+require github.com/avast/retry-go/v4 v4.3.4
pkg/mock/components/lock/lock.go (1)

Mock regeneration is needed due to SDK relocation

The git logs show that the go-sdk was moved to a separate repo on Nov 7, 2024. While this mock file is for the LockStore interface from mosn.io/layotto/components/lock (not the SDK), it's recommended to regenerate all mocks after such a significant change to ensure consistency and proper dependency updates.

  • pkg/mock/components/lock/lock.go: Regenerate this mock using mockgen
🔗 Analysis chain

Line range hint 1-1: Verify if mock regeneration is needed.

Since this is a generated file (as indicated by the header comment), please verify if this mock needs to be regenerated after moving the SDK to ensure all dependencies are correctly updated.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the source file for this mock has been moved or modified
# This will help determine if mock regeneration is needed

# Find the source file mentioned in the generation comment
rg -l "lock_store.go" --type go

# Check if there are any references to the old SDK path in the source file
rg "mosn.io/layotto/sdk/go-sdk" --type go

Length of output: 106


Script:

#!/bin/bash
# Let's check the content of the mock file and its imports
cat pkg/mock/components/lock/lock.go

# Also check for any mockgen related comments that might indicate the source
rg -A 5 "mockgen" pkg/mock/components/lock/lock.go

Length of output: 3726


Script:

#!/bin/bash
# Let's find the source file that this mock was generated from
fd lock_store.go

# And check its content to see if it's been modified
rg -l "LockStore" --type go

# Check if there are any recent changes to lock-related files
git log --since="1 month ago" -- "**/lock*.go"

Length of output: 1115

demo/configuration/common/client.go (1)

Line range hint 1-249: Consider enhancing documentation for SDK migration.

Since this is a demo file showcasing both SDK and gRPC usage patterns, it would be helpful to:

  1. Add comments explaining the differences between SDK and gRPC approaches
  2. Document any version compatibility requirements with the new SDK
  3. Include examples of handling potential SDK-specific errors

Would you like me to help generate improved documentation for this demo file?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b4fed4d and 347c550.

⛔ Files ignored due to path filters (5)
  • demo/go.sum is excluded by !**/*.sum
  • demo/state/k8s/go.sum is excluded by !**/*.sum
  • sdk/go-sdk/go.sum is excluded by !**/*.sum
  • spec/proto/extension/v1/s3/oss.pb.go is excluded by !**/*.pb.go
  • spec/proto/extension/v1/s3/oss_grpc.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (42)
  • components/pluggable/grpc_mock.go (0 hunks)
  • components/sequencer/snowflake/snowflake.go (1 hunks)
  • components/sequencer/snowflake/snowflake_sequencer.go (0 hunks)
  • components/sequencer/snowflake/snowflake_sequencer_test.go (0 hunks)
  • components/sequencer/snowflake/snowflake_test.go (0 hunks)
  • demo/configuration/common/client.go (1 hunks)
  • demo/go.mod (1 hunks)
  • demo/hello/common/client.go (1 hunks)
  • demo/lock/common/client.go (1 hunks)
  • demo/pubsub/client/publish_client.go (1 hunks)
  • demo/secret/common/client.go (1 hunks)
  • demo/sequencer/common/client.go (1 hunks)
  • demo/state/common/client.go (1 hunks)
  • demo/state/k8s/client.go (1 hunks)
  • demo/state/k8s/go.mod (1 hunks)
  • make/common.mk (0 hunks)
  • make/golang.mk (0 hunks)
  • pkg/mock/components/lock/lock.go (1 hunks)
  • sdk/go-sdk/client/client.go (0 hunks)
  • sdk/go-sdk/client/client_generated.go (0 hunks)
  • sdk/go-sdk/client/client_test.go (0 hunks)
  • sdk/go-sdk/client/configuration.go (0 hunks)
  • sdk/go-sdk/client/configuration_test.go (0 hunks)
  • sdk/go-sdk/client/goroutine.go (0 hunks)
  • sdk/go-sdk/client/goroutine_test.go (0 hunks)
  • sdk/go-sdk/client/hello.go (0 hunks)
  • sdk/go-sdk/client/hello_test.go (0 hunks)
  • sdk/go-sdk/client/invoke.go (0 hunks)
  • sdk/go-sdk/client/invoke_test.go (0 hunks)
  • sdk/go-sdk/client/lock.go (0 hunks)
  • sdk/go-sdk/client/lock_test.go (0 hunks)
  • sdk/go-sdk/client/pubsub.go (0 hunks)
  • sdk/go-sdk/client/pubsub_test.go (0 hunks)
  • sdk/go-sdk/client/secret.go (0 hunks)
  • sdk/go-sdk/client/secret_test.go (0 hunks)
  • sdk/go-sdk/client/sequencer.go (0 hunks)
  • sdk/go-sdk/client/state.go (0 hunks)
  • sdk/go-sdk/client/state_test.go (0 hunks)
  • sdk/go-sdk/go.mod (0 hunks)
  • sdk/go-sdk/test/runtime/integrate_test.go (0 hunks)
  • sdk/go-sdk/test/runtime/integrate_test.sh (0 hunks)
  • sdk/go-sdk/test/runtime/zkCreateZnode.sh (0 hunks)
💤 Files with no reviewable changes (30)
  • components/pluggable/grpc_mock.go
  • components/sequencer/snowflake/snowflake_sequencer.go
  • components/sequencer/snowflake/snowflake_sequencer_test.go
  • components/sequencer/snowflake/snowflake_test.go
  • make/common.mk
  • make/golang.mk
  • sdk/go-sdk/client/client.go
  • sdk/go-sdk/client/client_generated.go
  • sdk/go-sdk/client/client_test.go
  • sdk/go-sdk/client/configuration.go
  • sdk/go-sdk/client/configuration_test.go
  • sdk/go-sdk/client/goroutine.go
  • sdk/go-sdk/client/goroutine_test.go
  • sdk/go-sdk/client/hello.go
  • sdk/go-sdk/client/hello_test.go
  • sdk/go-sdk/client/invoke.go
  • sdk/go-sdk/client/invoke_test.go
  • sdk/go-sdk/client/lock.go
  • sdk/go-sdk/client/lock_test.go
  • sdk/go-sdk/client/pubsub.go
  • sdk/go-sdk/client/pubsub_test.go
  • sdk/go-sdk/client/secret.go
  • sdk/go-sdk/client/secret_test.go
  • sdk/go-sdk/client/sequencer.go
  • sdk/go-sdk/client/state.go
  • sdk/go-sdk/client/state_test.go
  • sdk/go-sdk/go.mod
  • sdk/go-sdk/test/runtime/integrate_test.go
  • sdk/go-sdk/test/runtime/integrate_test.sh
  • sdk/go-sdk/test/runtime/zkCreateZnode.sh
✅ Files skipped from review due to trivial changes (6)
  • components/sequencer/snowflake/snowflake.go
  • demo/hello/common/client.go
  • demo/lock/common/client.go
  • demo/pubsub/client/publish_client.go
  • demo/secret/common/client.go
  • demo/sequencer/common/client.go
🔇 Additional comments (8)
demo/state/k8s/go.mod (2)

17-17: Verify compatibility between go-sdk and spec versions

The spec dependency has been updated to a newer version. Please ensure that this version is compatible with the new go-sdk implementation.

#!/bin/bash
# Check the relationship between spec and SDK versions
gh api repos/layotto/go-sdk/commits/e55ee5816d2f --jq '.files[] | select(.filename | contains("go.mod"))' | grep "mosn.io/layotto/spec"

# Get the changelog or commit message for the spec update
git ls-remote https://github.com/mosn/layotto.git | grep b4fed4d06be4

9-9: Verify go-sdk version and consider using a tagged release

The current pseudo-version (v0.0.0-20241113124402-e55ee5816d2f) points to a specific commit. While this works, using a tagged release would provide better stability and clarity.

✅ Verification successful

Let me try another verification approach to check the repository tags and recent commits.


Let me try one more time with corrected commands:


Using commit hash is appropriate for now

The go-sdk repository is newly created (earliest commit is about initializing the source code) and doesn't have any tagged releases yet. The specified commit (e55ee5816d2f) is actually the latest merge commit from November 13, 2024, which fixed CI issues. Using this specific commit hash is currently the most stable approach until official releases are tagged.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any tagged releases for the new SDK
gh api repos/layotto/go-sdk/releases --jq '.[].tag_name'

# Get the commit hash this version points to
git ls-remote https://github.com/layotto/go-sdk.git | grep e55ee5816d2f

Length of output: 310


Script:

#!/bin/bash
# Check tags in the go-sdk repository
git ls-remote --tags https://github.com/layotto/go-sdk.git

# Get recent commits to understand the timeline
gh api repos/layotto/go-sdk/commits --per-page 5 --jq '.[].commit.message'

Length of output: 1506


Script:

#!/bin/bash
# Check tags in the go-sdk repository
git ls-remote --tags https://github.com/layotto/go-sdk.git

# Get recent commits using a different approach
gh api repos/layotto/go-sdk/commits?per_page=5 --jq '.[].commit.message'

# Also check if the specific commit exists and its date
gh api repos/layotto/go-sdk/commits/e55ee5816d2f --jq '{message: .commit.message, date: .commit.author.date}'

Length of output: 712

demo/go.mod (2)

27-27: Verify spec dependency version

The spec dependency version has been updated and the local replace directive is maintained. Let's verify this is the correct version:

#!/bin/bash
# Description: Verify spec dependency version matches the intended commit
# Expected: Confirm the version hash corresponds to the correct commit

# Check the commit in spec directory
cd spec && git rev-parse HEAD

# Verify this commit exists in the spec directory
git cat-file -e e55ee5816d2f 2>/dev/null && echo "Commit exists" || echo "Commit not found"

Also applies to: 30-32


26-26: Consider using a stable version constraint

The go-sdk dependency is using a pre-release version (0.0.0) with a specific commit hash. This could lead to stability issues. Consider:

  1. Using a stable release version when available
  2. Adding explicit version constraints to prevent breaking changes
✅ Verification successful

Let me try another approach to verify the version information.


Pre-release version is correct for now

The version github.com/layotto/go-sdk v0.0.0-20241113124402-e55ee5816d2f points to the latest commit (e55ee5816d2f) from November 13, 2024. Since the repository is relatively new and doesn't have any releases yet, using the latest commit hash is appropriate at this stage. No action needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check available versions and tags for go-sdk
# Expected: Find latest stable version if available

# Check if there are any tags/releases
gh api repos/layotto/go-sdk/tags --jq '.[].name'

# Check the commit hash to verify it's the latest intended version
gh api repos/layotto/go-sdk/commits/e55ee5816d2f --jq '.sha'

Length of output: 145


Script:

#!/bin/bash
# Check if the repository exists and get basic info
gh api repos/layotto/go-sdk --jq '.default_branch, .created_at'

# List recent commits on main branch
gh api repos/layotto/go-sdk/commits --jq '.[0:3] | .[] | {sha: .sha, date: .commit.author.date, message: .commit.message}'

# Check if there are any releases
gh api repos/layotto/go-sdk/releases --jq '.[].tag_name'

Length of output: 767

pkg/mock/components/lock/lock.go (1)

12-12: LGTM! Import path change looks correct.

The import path for the lock package remains internal to the project and is not affected by the SDK move.

demo/state/common/client.go (1)

24-24: LGTM! Import path updated correctly.

The import path change from mosn.io/layotto/sdk/go-sdk to github.com/layotto/go-sdk aligns with moving the SDK to a separate repository.

The previous review comment about import path inconsistency in demo/state/k8s/go.mod is still valid and needs to be addressed.

demo/state/k8s/client.go (1)

28-28: LGTM: Import path correctly updated for SDK migration

The import path change aligns with the PR objective of moving the Go SDK to a separate repository.

Let's verify that this is the only instance of the old import path in this file:

✅ Verification successful

Import path migration verified and consistent

The verification confirms that:

  • The file correctly uses the new import path github.com/layotto/go-sdk/client
  • No traces of the old import path mosn.io/layotto/sdk/go-sdk/client remain in this file
  • The change is consistent with other demo files which also use the new import path
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining old SDK import paths in this file
rg "mosn\.io/layotto/sdk/go-sdk" demo/state/k8s/client.go

Length of output: 59


Script:

#!/bin/bash
# Let's verify both the old and new import paths in the file
echo "=== Content of demo/state/k8s/client.go ==="
cat demo/state/k8s/client.go

# Also check if there are any other files using either import path
echo -e "\n=== Files using old SDK import path ==="
rg -l "mosn\.io/layotto/sdk/go-sdk/client" 

echo -e "\n=== Files using new SDK import path ==="
rg -l "github\.com/layotto/go-sdk/client"

Length of output: 4782

demo/configuration/common/client.go (1)

30-30: LGTM! Import path updated correctly.

The import path change from mosn.io/layotto/sdk/go-sdk/client to github.com/layotto/go-sdk/client aligns with the PR objective of moving the go-sdk to a separate repository.

Let's verify the SDK compatibility and version:

Signed-off-by: “huazhongming” <[email protected]>
@zhenjunMa zhenjunMa enabled auto-merge (squash) November 18, 2024 15:04
@zhenjunMa zhenjunMa merged commit 576685d into mosn:main Nov 18, 2024
25 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants