-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NETOBSERV-1471 add gRPC write stage (#621)
* add grpc write stage * add testing
- Loading branch information
1 parent
53e97a5
commit ddc1f67
Showing
12 changed files
with
673 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package api | ||
|
||
import "errors" | ||
|
||
type WriteGRPC struct { | ||
TargetHost string `yaml:"targetHost,omitempty" json:"targetHost,omitempty" doc:"the host name or IP of the target Flow collector"` | ||
TargetPort int `yaml:"targetPort,omitempty" json:"targetPort,omitempty" doc:"the port of the target Flow collector"` | ||
} | ||
|
||
func (w *WriteGRPC) Validate() error { | ||
if w == nil { | ||
return errors.New("you must provide a configuration") | ||
} | ||
if w.TargetHost == "" { | ||
return errors.New("targetHost can't be empty") | ||
} | ||
if w.TargetPort == 0 { | ||
return errors.New("targetPort can't be empty") | ||
} | ||
return nil | ||
} |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package grpc | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
|
||
pb "github.com/netobserv/flowlogs-pipeline/pkg/pipeline/write/grpc/genericmap" | ||
"github.com/netobserv/netobserv-ebpf-agent/pkg/utils" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
) | ||
|
||
// ClientConnection wraps a gRPC+protobuf connection | ||
type ClientConnection struct { | ||
client pb.CollectorClient | ||
conn *grpc.ClientConn | ||
} | ||
|
||
func ConnectClient(hostIP string, hostPort int) (*ClientConnection, error) { | ||
flag.Parse() | ||
// Set up a connection to the server. | ||
socket := utils.GetSocket(hostIP, hostPort) | ||
conn, err := grpc.Dial(socket, grpc.WithTransportCredentials(insecure.NewCredentials())) | ||
if err != nil { | ||
log.Fatalf("did not connect: %v", err) | ||
} | ||
|
||
return &ClientConnection{ | ||
client: pb.NewCollectorClient(conn), | ||
conn: conn, | ||
}, nil | ||
} | ||
|
||
func (cp *ClientConnection) Client() pb.CollectorClient { | ||
return cp.client | ||
} | ||
|
||
func (cp *ClientConnection) Close() error { | ||
return cp.conn.Close() | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
105 changes: 105 additions & 0 deletions
105
pkg/pipeline/write/grpc/genericmap/genericmap_grpc.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.