31 lines
785 B
Go

package integration
import (
"context"
userv1 "hyapp.local/api/proto/user/v1"
)
// AppRegistryClient keeps tenant discovery behind user-service, the owner of the App registry.
type AppRegistryClient struct {
client userv1.AppRegistryServiceClient
}
func NewAppRegistryClient(client userv1.AppRegistryServiceClient) *AppRegistryClient {
return &AppRegistryClient{client: client}
}
func (c *AppRegistryClient) ListEnabledAppCodes(ctx context.Context) ([]string, error) {
resp, err := c.client.ListApps(ctx, &userv1.ListAppsRequest{})
if err != nil {
return nil, err
}
appCodes := make([]string, 0, len(resp.GetApps()))
for _, app := range resp.GetApps() {
if app.GetStatus() == "active" {
appCodes = append(appCodes, app.GetAppCode())
}
}
return appCodes, nil
}