/
domain.go
92 lines (78 loc) · 2.88 KB
/
domain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Code generated by cdpgen. DO NOT EDIT.
// Package log implements the Log domain. Provides access to log entries.
package log
import (
"context"
"github.com/mafredri/cdp/protocol/internal"
"github.com/mafredri/cdp/rpcc"
)
// domainClient is a client for the Log domain. Provides access to log
// entries.
type domainClient struct{ conn *rpcc.Conn }
// NewClient returns a client for the Log domain with the connection set to conn.
func NewClient(conn *rpcc.Conn) *domainClient {
return &domainClient{conn: conn}
}
// Clear invokes the Log method. Clears the log.
func (d *domainClient) Clear(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Log.clear", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Log", Op: "Clear", Err: err}
}
return
}
// Disable invokes the Log method. Disables log domain, prevents further log
// entries from being reported to the client.
func (d *domainClient) Disable(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Log.disable", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Log", Op: "Disable", Err: err}
}
return
}
// Enable invokes the Log method. Enables log domain, sends the entries
// collected so far to the client by means of the `entryAdded` notification.
func (d *domainClient) Enable(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Log.enable", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Log", Op: "Enable", Err: err}
}
return
}
// StartViolationsReport invokes the Log method. start violation reporting.
func (d *domainClient) StartViolationsReport(ctx context.Context, args *StartViolationsReportArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Log.startViolationsReport", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Log.startViolationsReport", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Log", Op: "StartViolationsReport", Err: err}
}
return
}
// StopViolationsReport invokes the Log method. Stop violation reporting.
func (d *domainClient) StopViolationsReport(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Log.stopViolationsReport", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Log", Op: "StopViolationsReport", Err: err}
}
return
}
func (d *domainClient) EntryAdded(ctx context.Context) (EntryAddedClient, error) {
s, err := rpcc.NewStream(ctx, "Log.entryAdded", d.conn)
if err != nil {
return nil, err
}
return &entryAddedClient{Stream: s}, nil
}
type entryAddedClient struct{ rpcc.Stream }
// GetStream returns the original Stream for use with cdp.Sync.
func (c *entryAddedClient) GetStream() rpcc.Stream { return c.Stream }
func (c *entryAddedClient) Recv() (*EntryAddedReply, error) {
event := new(EntryAddedReply)
if err := c.RecvMsg(event); err != nil {
return nil, &internal.OpError{Domain: "Log", Op: "EntryAdded Recv", Err: err}
}
return event, nil
}