-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from jzelinskie/multiclients
reorganize package to support multiple clients
- Loading branch information
Showing
19 changed files
with
117 additions
and
164 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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,30 @@ | ||
package authzed | ||
|
||
import ( | ||
"github.com/jzelinskie/stringz" | ||
"google.golang.org/grpc" | ||
|
||
v1alpha1 "github.com/authzed/authzed-go/proto/authzed/api/v1alpha1" | ||
) | ||
|
||
// Client represents an open connection to Authzed. | ||
// | ||
// Clients are backed by a gRPC client and as such are thread-safe. | ||
type Client struct { | ||
v1alpha1.SchemaServiceClient | ||
} | ||
|
||
// NewClient initializes a brand new client for interacting with Authzed. | ||
func NewClient(endpoint string, opts ...grpc.DialOption) (*Client, error) { | ||
conn, err := grpc.Dial( | ||
stringz.DefaultEmpty(endpoint, "grpc.authzed.com:443"), | ||
opts..., | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &Client{ | ||
v1alpha1.NewSchemaServiceClient(conn), | ||
}, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package authzed_test | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"testing" | ||
|
||
"github.com/authzed/grpcutil" | ||
|
||
authzed "github.com/authzed/authzed-go/v1alpha1" | ||
) | ||
|
||
func ExampleNewClient(_ *testing.T) { | ||
client, err := authzed.NewClient( | ||
"grpc.authzed.com:443", | ||
grpcutil.WithBearerToken("tc_my_token_deadbeefdeadbeefdeadbeef"), | ||
grpcutil.WithSystemCerts(false), | ||
) | ||
if err != nil { | ||
log.Fatalf("failed to connect to authzed: %s", err) | ||
} | ||
fmt.Println(client) | ||
} |
Oops, something went wrong.