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

Non-REST/Go native client #37

Open
kokizzu opened this issue Jul 9, 2020 · 1 comment
Open

Non-REST/Go native client #37

kokizzu opened this issue Jul 9, 2020 · 1 comment

Comments

@kokizzu
Copy link

kokizzu commented Jul 9, 2020

Just like redigo/go-redis or aerospike-client-go

@kokizzu kokizzu changed the title Non REST/Go native client Non-REST/Go native client Jul 9, 2020
@vniche
Copy link
Contributor

vniche commented Jul 11, 2020

I don't really see the point since it is a gRPC Service, it should be consumed via gRPC client, eg.:

import (
        ceteProto "github.com/mosuka/cete/protobuf"
        "google.golang.org/grpc"
)

type Data struct {
	UID string
	Data string
}

dialOpts := append([]grpc.DialOption{},
    grpc.WithInsecure(),
    grpc.WithDefaultCallOptions(grpc.EmptyCallOption{}))
conn, err := grpc.Dial(":9000", dialOpts...)
if err != nil {
    log.Fatal(err)
}

client := ceteProto.NewKVSClient(conn)

data := &Data{
    UID: "123",
    Data: "test",
}

dataJson, err := json.Marshal(data)
if err != nil {
    log.Fatal(err)
}

_, err = client.Set(context.Background(), &ceteProto.SetRequest{
    Key:   data.UID,
    Value: dataJson,
})
if err != nil {
    return "", err
}

I've experimented on this repository: https://github.com/vniche/users-microservice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants