-
Notifications
You must be signed in to change notification settings - Fork 43
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
docs: update onboarding steps for Go v3 client #6987
Open
karel-rehor
wants to merge
2
commits into
master
Choose a base branch
from
update-onboarding-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+97
−109
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,8 @@ export const WriteDataComponent = (props: OwnProps) => { | |
onSelectBucket(bucket.name) | ||
}, [bucket, onSelectBucket]) | ||
|
||
const codeSnippet = `org := "${org.name}" | ||
const codeSnippet = `// FOO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the |
||
org := "${org.name}" | ||
bucket := "${bucket.name}" | ||
writeAPI := client.WriteAPIBlocking(org, bucket) | ||
for value := 0; value < 5; value++ { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,13 +61,14 @@ export const WriteDataSqlComponent = (props: OwnProps) => { | |
}, [bucket, onSelectBucket]) | ||
|
||
const initializeCodeSnippet = `package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
"os" | ||
|
||
"github.com/InfluxCommunity/influxdb3-go/influxdb3" | ||
"github.com/InfluxCommunity/influxdb3-go/v2/influxdb3" | ||
) | ||
|
||
func main() { | ||
|
@@ -95,55 +96,61 @@ func main() { | |
database := "${bucket.name}" | ||
}` | ||
|
||
const writeCodeSnippet = `data := map[string]map[string]interface{}{ | ||
"point1": { | ||
"location": "Klamath", | ||
"species": "bees", | ||
"count": 23, | ||
}, | ||
"point2": { | ||
"location": "Portland", | ||
"species": "ants", | ||
"count": 30, | ||
}, | ||
"point3": { | ||
"location": "Klamath", | ||
"species": "bees", | ||
"count": 28, | ||
}, | ||
"point4": { | ||
"location": "Portland", | ||
"species": "ants", | ||
"count": 32, | ||
}, | ||
"point5": { | ||
"location": "Klamath", | ||
"species": "bees", | ||
"count": 29, | ||
}, | ||
"point6": { | ||
"location": "Portland", | ||
"species": "ants", | ||
"count": 40, | ||
}, | ||
} | ||
const writeCodeSnippet = ` data := map[string]map[string]interface{}{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious to see what effect this whitespace has on the snippet |
||
"point1": { | ||
"location": "Klamath", | ||
"species": "bees", | ||
"count": 23, | ||
}, | ||
"point2": { | ||
"location": "Portland", | ||
"species": "ants", | ||
"count": 30, | ||
}, | ||
"point3": { | ||
"location": "Klamath", | ||
"species": "bees", | ||
"count": 28, | ||
}, | ||
"point4": { | ||
"location": "Portland", | ||
"species": "ants", | ||
"count": 32, | ||
}, | ||
"point5": { | ||
"location": "Klamath", | ||
"species": "bees", | ||
"count": 29, | ||
}, | ||
"point6": { | ||
"location": "Portland", | ||
"species": "ants", | ||
"count": 40, | ||
}, | ||
} | ||
|
||
// Write data | ||
options := influxdb3.WriteOptions{ | ||
Database: database, | ||
} | ||
for key := range data { | ||
point := influxdb3.NewPointWithMeasurement("census"). | ||
AddTag("location", data[key]["location"].(string)). | ||
AddField(data[key]["species"].(string), data[key]["count"]) | ||
// convert data to Points | ||
points := []*influxdb3.Point{} | ||
// start time stamp | ||
stamp := time.Now().Add(time.Duration(len(data)) * time.Second * -1) | ||
|
||
if err := client.WritePointsWithOptions(context.Background(), &options, point); err != nil { | ||
panic(err) | ||
for key := range data { | ||
points = append(points, | ||
influxdb3.NewPointWithMeasurement("census"). | ||
SetTag("location", data[key]["location"].(string)). | ||
SetIntegerField(data[key]["species"].(string), | ||
int64(data[key]["count"].(int))). | ||
SetTimestamp(stamp)) | ||
stamp = stamp.Add(time.Second) // Add a second to the stamp | ||
} | ||
|
||
time.Sleep(1 * time.Second) // separate points by 1 second | ||
} | ||
|
||
// Write data | ||
fmt.Printf("Writing %d points\\n", len(points)) | ||
if err := client.WritePoints(context.Background(), | ||
points, | ||
influxdb3.WithDatabase(database)); err != nil { | ||
panic(err) | ||
} | ||
` | ||
|
||
return ( | ||
|
@@ -328,7 +335,7 @@ for key := range data { | |
<CodeSnippet | ||
language="properties" | ||
onCopy={logCopyRunCodeSnippet} | ||
text="go run ./main.go" | ||
text="go mod tidy && go run ./main.go" | ||
/> | ||
<p> | ||
The program should write data once you run it. After the data is | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also curious about the whitespace here, looks like the number of spaces in a tab has changed, is that maintained across all snippets in the go onboarding?