grpc: rename internal/grpc to pkg/grpc (#1010)

* grpc: rename internal/grpc to pkg/grpc

* don't ignore pkg dir

* remove debug line
This commit is contained in:
Caleb Doxsey 2020-06-26 09:17:02 -06:00 committed by GitHub
parent a98d39c5af
commit 091b71f12e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 247 additions and 927 deletions

View file

@ -0,0 +1,30 @@
// Package session contains protobuf types for sessions.
package session
import (
context "context"
"github.com/golang/protobuf/ptypes"
"github.com/pomerium/pomerium/pkg/grpc/databroker"
)
// Get gets a session from the databroker.
func Get(ctx context.Context, client databroker.DataBrokerServiceClient, sessionID string) (*Session, error) {
any, _ := ptypes.MarshalAny(new(Session))
res, err := client.Get(ctx, &databroker.GetRequest{
Type: any.GetTypeUrl(),
Id: sessionID,
})
if err != nil {
return nil, err
}
var s Session
err = ptypes.UnmarshalAny(res.GetRecord().GetData(), &s)
if err != nil {
return nil, err
}
return &s, nil
}