Skip to content

Commit

Permalink
chore(readme): update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Umaaz committed May 29, 2023
1 parent 3c3af2f commit 9f5f246
Showing 1 changed file with 84 additions and 3 deletions.
87 changes: 84 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,86 @@
# go-deep-proto
# Go Deep Proto
This is the generated code for the common APIs for DEEP. This is generated from the project [intergra/deep-proto](https://github.com/intergral/deep-proto).

This is the GO compiled version of the protobuf created from the [deep-proto](https://github.com/intergral/deep-proto) project.
# Usage
The usage of these packages differs between server and clients. Please see [GRPC docs](https://grpc.io/docs/languages/go/) for more guidance.

The source in this project is updated automatically by the build in the deep-proto project.
## Client
To use this as a client:

```go
import (
tp "github.com/intergral/go-deep-proto/tracepoint/v1"
pb "github.com/intergral/go-deep-proto/poll/v1"
)

func sendPoll(){
// create grpc connection
var opts []grpc.DialOption
...
conn, err := grpc.Dial(*serverAddr, opts...)
defer conn.Close()

// create client
client := pb.NewPollConfigClient(conn)
// send poll request
response, err := client.Poll(context.Background(), &pb.PollRequest{})
}

func sendSnapshot(){
// create grpc connection
var opts []grpc.DialOption
...
conn, err := grpc.Dial(*serverAddr, opts...)
defer conn.Close()

// create client
client := tp.NewSnapshotServiceClient(conn)
// send snapshot
response, err := client.Send(context.Background(), &pb.PollRequest{})
}
```

## Server
To use this as a server:

```go
import (
tp "github.com/intergral/go-deep-proto/tracepoint/v1"
pb "github.com/intergral/go-deep-proto/poll/v1"
)

type TPServer struct {}

func (TPServer) Send(ctx context.Context, in *tp.Snapshot) (*tp.SnapshotResponse, error) {
// process new snapshot
return &tp.SnapshotResponse{}, nil
}

type PollServer struct {}

func (PollServer) Poll(ctx context.Context, pollRequest *pb.PollRequest) (*pb.PollResponse, error) {
// process new poll request
returng &pb.PollResponse{}, nil
}

func setup() {
// setup network
lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", *port))
// setup grpc server
var opts []grpc.ServerOption
grpcServer := grpc.NewServer(opts...)
// register services
pb.RegisterPollConfigServer(t.Server.GRPC, PollServer())
tp.RegisterSnapshotServiceServer(t.Server.GRPC, TPServer())
// start server
grpcServer.Serve(lis)
}


```

# Documentation
The documentation for this project is available [here](https://intergral.github.io/deep-proto/common/).

# Licensing
This project is licensed as [AGPL-3.0-only](./LICENSE).

0 comments on commit 9f5f246

Please sign in to comment.