-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49637c2
commit 042ae62
Showing
33 changed files
with
4,332 additions
and
1,186 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
package nrjmx | ||
|
||
import ( | ||
"context" | ||
|
||
"time" | ||
|
||
"github.com/apache/thrift/lib/go/thrift" | ||
"github.com/newrelic/nrjmx/nrprotocol" | ||
) | ||
|
||
func NewJMXServiceClient(ctx context.Context) (client *JMXClient, err error) { | ||
jmxProcess, err := startJMXProcess(ctx) | ||
if err != nil { | ||
return | ||
} | ||
|
||
var protocolFactory thrift.TProtocolFactory | ||
protocolFactory = thrift.NewTCompactProtocolFactory() | ||
|
||
var transportFactory thrift.TTransportFactory | ||
|
||
transportFactory = thrift.NewTBufferedTransportFactory(8192) | ||
|
||
transportFactory = thrift.NewTFramedTransportFactory(transportFactory) | ||
|
||
var transport thrift.TTransport | ||
|
||
transport = thrift.NewStreamTransport(jmxProcess.Stdout, jmxProcess.Stdin) | ||
transport, err = transportFactory.GetTransport(transport) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
iprot := protocolFactory.GetProtocol(transport) | ||
oprot := protocolFactory.GetProtocol(transport) | ||
client = &JMXClient{ | ||
JMXService: nrprotocol.NewJMXServiceClient(thrift.NewTStandardClient(iprot, oprot)), | ||
jmxProcess: *jmxProcess, | ||
ctx: ctx, | ||
} | ||
return | ||
} | ||
|
||
type JMXClient struct { | ||
nrprotocol.JMXService | ||
jmxProcess jmxProcess | ||
ctx context.Context | ||
} | ||
|
||
func (j *JMXClient) Close(timeout time.Duration) error { | ||
j.Disconnect(j.ctx) | ||
return j.jmxProcess.stop(timeout) | ||
} |
Oops, something went wrong.