• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ory / keto / 10166504429

30 Jul 2024 04:53PM CUT coverage: 77.612%. First build
10166504429

Pull #1559

github

zepatrik
chore: bump ory/x
Pull Request #1559: chore: bump dependencies

5734 of 7388 relevant lines covered (77.61%)

489.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/contrib/docs-code-samples/list-api-display-objects/00-create-tuples/main.go
1
// Copyright © 2023 Ory Corp
2
// SPDX-License-Identifier: Apache-2.0
3

4
package main
5

6
import (
7
        "context"
8
        "fmt"
9

10
        "google.golang.org/grpc"
11
        "google.golang.org/grpc/credentials/insecure"
12

13
        rts "github.com/ory/keto/proto/ory/keto/relation_tuples/v1alpha2"
14
)
15

16
func main() {
×
17
        conn, err := grpc.Dial("127.0.0.1:4467", grpc.WithTransportCredentials(insecure.NewCredentials()))
×
18
        if err != nil {
×
19
                panic("Encountered error: " + err.Error())
×
20
        }
21

22
        client := rts.NewWriteServiceClient(conn)
×
23

×
24
        var tuples []*rts.RelationTuple
×
25
        // memes
×
26
        for _, user := range []string{"PM", "Vincent", "Julia"} {
×
27
                tuples = append(tuples, &rts.RelationTuple{
×
28
                        Namespace: "chats",
×
29
                        Object:    "memes",
×
30
                        Relation:  "member",
×
31
                        Subject:   rts.NewSubjectID(user),
×
32
                })
×
33
        }
×
34
        // cars
35
        for _, user := range []string{"PM", "Julia"} {
×
36
                tuples = append(tuples, &rts.RelationTuple{
×
37
                        Namespace: "chats",
×
38
                        Object:    "cars",
×
39
                        Relation:  "member",
×
40
                        Subject:   rts.NewSubjectID(user),
×
41
                })
×
42
        }
×
43
        // coffee-break
44
        for _, user := range []string{"PM", "Vincent", "Julia", "Patrik"} {
×
45
                tuples = append(tuples, &rts.RelationTuple{
×
46
                        Namespace: "chats",
×
47
                        Object:    "coffee-break",
×
48
                        Relation:  "member",
×
49
                        Subject:   rts.NewSubjectID(user),
×
50
                })
×
51
        }
×
52

53
        _, err = client.TransactRelationTuples(context.Background(), &rts.TransactRelationTuplesRequest{
×
54
                RelationTupleDeltas: rts.RelationTupleToDeltas(tuples, rts.RelationTupleDelta_ACTION_INSERT),
×
55
        })
×
56
        if err != nil {
×
57
                panic("Encountered error: " + err.Error())
×
58
        }
59

60
        fmt.Println("Successfully created tuples")
×
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc