Skip to content

Commit

Permalink
Merge pull request #6 from nukokusa/feature/update-dependencies
Browse files Browse the repository at this point in the history
update dependencies
  • Loading branch information
nukokusa committed Oct 16, 2023
2 parents b015ba9 + 1dc5f27 commit f282ab8
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 82 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -4,13 +4,13 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dominikh/staticcheck-action@v1.3.0
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"
- run: go test -race -v ./...
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Expand Up @@ -9,13 +9,13 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- uses: goreleaser/goreleaser-action@v4
go-version-file: "go.mod"
- uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
Expand Down
5 changes: 2 additions & 3 deletions .goreleaser.yml
Expand Up @@ -4,7 +4,7 @@ before:
- go mod download
builds:
- env:
- CGO_ENABLED=0
- CGO_ENABLED=0
main: ./cmd/koyomi/
binary: koyomi
ldflags:
Expand All @@ -18,8 +18,7 @@ builds:
- amd64
- arm64
release:
prerelease: true
archives:
prerelease: "true"
checksum:
name_template: "checksums.txt"
changelog:
Expand Down
29 changes: 13 additions & 16 deletions calendar.go
Expand Up @@ -65,24 +65,21 @@ type CalendarService interface {
}

type calendarService struct {
cs *calendar.Service
policy retry.Policy
cs *calendar.Service
}

var policy = retry.Policy{
MinDelay: time.Second,
MaxDelay: 100 * time.Second,
MaxCount: 10,
}

func newCalendarService(ctx context.Context, credentialPath string) (CalendarService, error) {
cs, err := calendar.NewService(ctx, option.WithCredentialsFile(credentialPath))
if err != nil {
return nil, errors.Wrap(err, "error calendar.NewService")
}
policy := retry.Policy{
MinDelay: time.Second,
MaxDelay: 100 * time.Second,
MaxCount: 10,
}
return &calendarService{
cs: cs,
policy: policy,
}, nil
return &calendarService{cs: cs}, nil
}

func (s *calendarService) List(ctx context.Context, calendarID string, startTime, endTime time.Time) ([]*Event, error) {
Expand All @@ -95,7 +92,7 @@ func (s *calendarService) List(ctx context.Context, calendarID string, startTime

pageToken := ""
for {
retrier := s.policy.Start(ctx)
retrier := policy.Start(ctx)
var resp *calendar.Events
for retrier.Continue() {
var err error
Expand Down Expand Up @@ -143,7 +140,7 @@ func (s *calendarService) Insert(ctx context.Context, calendarID string, event *
}
req := s.cs.Events.Insert(calendarID, ev)

retrier := s.policy.Start(ctx)
retrier := policy.Start(ctx)
var resp *calendar.Event
for retrier.Continue() {
var err error
Expand Down Expand Up @@ -187,7 +184,7 @@ func (s *calendarService) Update(ctx context.Context, calendarID string, event *
}
req := s.cs.Events.Update(calendarID, ev.Id, ev)

retrier := s.policy.Start(ctx)
retrier := policy.Start(ctx)
var resp *calendar.Event
for retrier.Continue() {
var err error
Expand All @@ -213,7 +210,7 @@ func (s *calendarService) Update(ctx context.Context, calendarID string, event *

func (s *calendarService) get(ctx context.Context, calendarID string, eventID string) (*calendar.Event, error) {
req := s.cs.Events.Get(calendarID, eventID)
retrier := s.policy.Start(ctx)
retrier := policy.Start(ctx)
var ev *calendar.Event
for retrier.Continue() {
var err error
Expand All @@ -235,7 +232,7 @@ func (s *calendarService) get(ctx context.Context, calendarID string, eventID st

func (s *calendarService) Delete(ctx context.Context, calendarID, eventID string) error {
req := s.cs.Events.Delete(calendarID, eventID)
retrier := s.policy.Start(ctx)
retrier := policy.Start(ctx)
for retrier.Continue() {
err := req.Context(ctx).Do()
if err == nil {
Expand Down
38 changes: 20 additions & 18 deletions go.mod
@@ -1,34 +1,36 @@
module github.com/nukokusa/koyomi

go 1.20
go 1.21

require (
github.com/Songmu/flextime v0.1.0
github.com/alecthomas/kong v0.7.1
github.com/google/go-cmp v0.5.9
github.com/alecthomas/kong v0.8.1
github.com/google/go-cmp v0.6.0
github.com/hashicorp/logutils v1.0.0
github.com/pkg/errors v0.9.1
github.com/shogo82148/go-retry v1.1.1
github.com/tkuchiki/parsetime v0.3.0
google.golang.org/api v0.114.0
google.golang.org/api v0.147.0
)

require (
cloud.google.com/go/compute v1.18.0 // indirect
cloud.google.com/go/compute v1.23.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/tkuchiki/go-timezone v0.2.2 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.29.1 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

0 comments on commit f282ab8

Please sign in to comment.