footprint-sdk is SDK to deal with footprint ingestor server
for the Footprint SDK for the Go programming language. This Developer Preview is provided to receive feedback from other
teams on SDK changes prior to the final release. As such users should expect the SDK to release minor version releases
that break backwards compatability. The release notes for the breaking change will include information about the
breaking change, and how you can migrate to the latest version.
Check out the [Issues] and [Projects] for design and updates being made to the SDK. The SDK requires a minimum version of Go 1.14.
We’ll be expanding out the [Issues] and [Projects] sections with additional changes to the SDK based on your feedback, and SDK’s core’s improvements. Check the the SDK’s [CHANGELOG] for information about the latest updates to the SDK.
Jump To:
Project Status
The SDK is in preview state as we work to design and implement potentially breaking changes to the SDK as we update the SDK’s layout and usage patterns based on your feedback. You can also expect periodic service API model updates as well.
We are actively seeking team feedback for several changes to the SDK. Please review our [design] page on issues that are currently pending team feedback.
Users should expect significant changes that could affect the following (non-exhaustive) areas:
- Service Footprint-ingestor
Getting started
The best way to get started working with the SDK is to use go get to add the SDK to your Go Workspace or application using Go modules.
git config --global url."git@git.teko.vn:".insteadOf "https://git.teko.vn/"
GOSUMDB=off
go get -u -v go.tekoapis.com/footprint
Quick Examples
Define your protobuf type
Submit a MR to the footprint-proto repository that defines the the protobuf type of the messages that
you would like to log to our system (an example can be seen here).
Once the MR is merged, we would publish the generated code to the footprint-dto repository
from which you can import the relevang golang packages.
Please note that we only support 1 single event/log type per proto file and thus assume that the first type defined in the proto is the event that you’d like to log to our system.
Hello Footprint
This example shows how you can use the SDK to make an API request using the SDK’s [Footprint-ingestor] client. It makes use of the protobuf defined in the example in the previous section.
package main
import (
"context"
"fmt"
"time"
"github.com/golang/protobuf/ptypes"
sdk "go.tekoapis.com/footprint/golang/sdk"
pb "go.tekoapis.com/footprint/golang/sdk/example/example/v1"
)
const (
defaultBaseURL = "localhost:8080"
defaultServiceName = "listing"
)
func main() {
// Define sdk config for your service.
var sdkConfig = &sdk.Config{
BaseURL: defaultBaseURL, // URL of footprint-ingestor.
ServiceName: defaultServiceName, // define your service name.
}
// Create a client instance to use sdk. By default, client will log the send request to stdout.
// The logged requests will be aggregated by Fluentbit and sent to Ingestor server periodically.
//
// You can also use different client by passing `WithGRPCClient` or `WithHTTPClient` option.
// Here's the list of options:
// - WithGRPCClient: set client to use gRPC endpoints.
// - WithHTTPClient: set client to use gRPC endpoints.
// - WithBlock: config dial blocking.
// - WithLogger: inject custom logger.
// - WithCurrentTimestampFn: set custom currentTimestampFn for SDK.
// - WithMarshalMessageFn: set a custom marshal function for messages.
client, _ := sdk.NewClient(sdk.WithGRPCClient(sdkConfig))
// Create message your service.
message := &pb.PageView{
Location: "location",
PageType: pb.PageType_PAGE_TYPE_CHECKOUT,
Referrer: &pb.Referrer{
Path: "google.com",
},
Timestamp: ptypes.TimestampNow(),
}
// Use context pass to sdk to handle timeout when call to footprint service.
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
// Create a send data to send to ingester server.
sendRequest, _ := client.NewSendRequest(message)
// Call Liveness func of sdk.
_, err := client.Liveness(ctx)
if err != nil {
fmt.Println(err)
}
response, err := client.Send(ctx, sendRequest)
if err != nil {
fmt.Println(err)
}
fmt.Println(response, err)
}
Getting Help
Please contact to my team for supporting . We use the GitLab issues for tracking bugs and feature requests.
Opening Issues
If you encounter a bug with the Footprint SDK for Go we would like to hear about it. Search the [existing issues][issues] and see if others are also experiencing the issue before opening a new issue. Please include the version of Footprint SDK for Go, Go language, and OS you’re using. Please also include reproduction case when appropriate.
The GitLab issues are intended for bug reports and feature requests. For help and questions with using Footprint SDK for Go.