Golang RELP library, allows the use of the RELP protocol in Golang.
Tested with Go v1.19.
Initializes an unencrypted RELP connection, and verifies each batch.
func main() {
relpSess := RelpConnection{RelpDialer: &RelpPlainDialer{}}
// OR: use RelpTLSDialer as the RelpDialer, and configure...
relpSess.Init()
// ...using relpSess.tlsConfig = &tls.Config{}
batch := RelpBatch{}
batch.Init()
batch.PutRequest(&RelpFrameTX{
RelpFrame{
cmd: "syslog",
dataLength: len([]byte("HelloWorld")),
data: []byte("HelloWorld"),
},
})
retry(&relpSess)
notDone := true
for notDone {
commitErr := relpSess.Commit(&batch)
if commitErr != nil {
log.Printf("Error committing batch: '%v'\n", commitErr.Error())
}
if !batch.VerifyTransactionAll() {
batch.RetryAllFailed()
retry(&relpSess)
} else {
notDone = false
}
}
relpSess.Disconnect()
fmt.Println(">>DONE<<")
// await for input, so the program doesn't exit
a := 0.0
fmt.Scanf("%f", &a)
}
func retry(relpSess *RelpConnection) {
relpSess.TearDown()
var cSuccess bool
var cErr error
cSuccess, cErr = relpSess.Connect("127.0.0.1", 1601)
for !cSuccess || cErr != nil {
relpSess.TearDown()
time.Sleep(5 * time.Second)
cSuccess, cErr = relpSess.Connect("127.0.0.1", 1601)
}
}
Method or field | Information |
---|---|
|
Initializes a TCP connection to the provided hostname:port address. |
|
Specifies whether to use |
|
Duration, which the connection waits for a new ACK. Timeout will return error to |
|
Duration, which the connection waits for a new write. Timeout will return error to |
|
Sends the RelpBatch given as the argument to the established RELP connection. |
|
Gracefully disconnects from the server. |
|
Forcefully disconnects from the server. |
|
Inserts a relp frame to the batch |
|
Verifies that all transactions got acknowledged by the server. Returns boolean. |
|
Adds all transactions back to the working queue. Restart the connection with tearDown+connect to try again. |
You can involve yourself with our project by opening an issue or submitting a pull request.
Contribution requirements:
-
All changes must be accompanied by a new or changed test. If you think testing is not required in your pull request, include a sufficient explanation as why you think so.
-
Security checks must pass
-
Pull requests must align with the principles and values of extreme programming.
-
Pull requests must follow the principles of Object Thinking and Elegant Objects (EO).
Read more in our Contributing Guideline.
Contributors must sign Teragrep Contributor License Agreement before a pull request is accepted to organization’s repositories.
You need to submit the CLA only once. After submitting the CLA you can contribute to all Teragrep’s repositories.