-
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.
Adds possibility to call BBS to retrieve stats for application's
processes states.
- Loading branch information
Showing
265 changed files
with
86,905 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package fetcher | ||
|
||
import ( | ||
"strings" | ||
"time" | ||
|
||
"code.cloudfoundry.org/bbs" | ||
"code.cloudfoundry.org/bbs/models" | ||
"code.cloudfoundry.org/bbs/trace" | ||
"code.cloudfoundry.org/lager/v3" | ||
) | ||
|
||
const ( | ||
clientSessionCacheSize int = -1 | ||
maxIdleConnsPerHost int = -1 | ||
) | ||
|
||
type BBSClient struct { | ||
client bbs.Client | ||
config *BBSConfig | ||
logger lager.Logger | ||
} | ||
|
||
type BBSConfig struct { | ||
URL string `yaml:"url"` | ||
Timeout int `yaml:"timeout"` | ||
CAFile string `yaml:"ca_file"` | ||
CertFile string `yaml:"cert_file"` | ||
KeyFile string `yaml:"key_file"` | ||
SkipCertVerify bool `yaml:"skip_cert_verify"` | ||
} | ||
|
||
func NewBBSClient(config *BBSConfig) (*BBSClient, error) { | ||
var err error | ||
bbsClient := BBSClient{ | ||
config: config, | ||
logger: lager.NewLogger("bbs-client"), | ||
} | ||
bbsClientConfig := bbs.ClientConfig{ | ||
URL: config.URL, | ||
Retries: 1, | ||
RequestTimeout: time.Duration(config.Timeout) * time.Second, | ||
} | ||
if strings.HasPrefix(config.URL, "https://") { | ||
bbsClientConfig.IsTLS = true | ||
bbsClientConfig.InsecureSkipVerify = config.SkipCertVerify | ||
bbsClientConfig.CAFile = config.CAFile | ||
bbsClientConfig.CertFile = config.CertFile | ||
bbsClientConfig.KeyFile = config.KeyFile | ||
bbsClientConfig.ClientSessionCacheSize = clientSessionCacheSize | ||
bbsClientConfig.MaxIdleConnsPerHost = maxIdleConnsPerHost | ||
} | ||
bbsClient.client, err = bbs.NewClientWithConfig(bbsClientConfig) | ||
return &bbsClient, err | ||
} | ||
|
||
func (b *BBSClient) GetActualLRPs() ([]*models.ActualLRP, error) { | ||
traceID := trace.GenerateTraceID() | ||
actualLRPs, err := b.client.ActualLRPs(b.logger, traceID, models.ActualLRPFilter{}) | ||
|
||
return actualLRPs, err | ||
} |
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
Oops, something went wrong.