Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
lmittmann committed May 7, 2023
1 parent a0fc9e3 commit ce7f1b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions client.go
Expand Up @@ -21,7 +21,7 @@ type Client struct {
}

// NewClient returns a new Client given an rpc.Client client.
func NewClient(client *rpc.Client, opts ...ClientOption) *Client {
func NewClient(client *rpc.Client, opts ...Option) *Client {
c := &Client{
client: client,
}
Expand All @@ -36,7 +36,7 @@ func NewClient(client *rpc.Client, opts ...ClientOption) *Client {
//
// The supported URL schemes are "http", "https", "ws" and "wss". If rawurl is a
// file name with no URL scheme, a local IPC socket connection is established.
func Dial(rawurl string, opts ...ClientOption) (*Client, error) {
func Dial(rawurl string, opts ...Option) (*Client, error) {
client, err := rpc.Dial(rawurl)
if err != nil {
return nil, err
Expand All @@ -45,7 +45,7 @@ func Dial(rawurl string, opts ...ClientOption) (*Client, error) {
}

// MustDial is like [Dial] but panics if the connection establishment fails.
func MustDial(rawurl string, opts ...ClientOption) *Client {
func MustDial(rawurl string, opts ...Option) *Client {
client, err := Dial(rawurl, opts...)
if err != nil {
panic(fmt.Sprintf("w3: %s", err))
Expand Down
6 changes: 3 additions & 3 deletions client_options.go
Expand Up @@ -2,13 +2,13 @@ package w3

import "golang.org/x/time/rate"

// A ClientOption configures a Client.
type ClientOption func(*Client)
// An Option configures a Client.
type Option func(*Client)

// WithRateLimiter sets the rate limiter for the client. If perCall is true, the
// rate limiter is applied to each call. Otherwise, the rate limiter is applied
// to each request.
func WithRateLimiter(rl *rate.Limiter, perCall bool) ClientOption {
func WithRateLimiter(rl *rate.Limiter, perCall bool) Option {
return func(c *Client) {
c.rl = rl
c.rlPerCall = perCall
Expand Down

0 comments on commit ce7f1b2

Please sign in to comment.