-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Reduce namespace polution by moving service examples into a…
… package
- Loading branch information
Showing
5 changed files
with
91 additions
and
83 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// (c) Cartesi and individual authors (see AUTHORS) | ||
// SPDX-License-Identifier: Apache-2.0 (see LICENSE) | ||
|
||
// A Service implementation that does nothing | ||
package dummy | ||
|
||
import ( | ||
"github.com/cartesi/rollups-node/pkg/service" | ||
) | ||
|
||
type Service struct { | ||
service.Service | ||
} | ||
|
||
type CreateInfo struct { | ||
service.CreateInfo | ||
} | ||
|
||
func Create(c *CreateInfo, s *Service) error { | ||
return service.Create(&c.CreateInfo, &s.Service) | ||
} | ||
|
||
func (s *Service) Alive() bool { return true } | ||
func (s *Service) Ready() bool { return true } | ||
func (s *Service) Reload() []error { return nil } | ||
func (s *Service) Tick() []error { return nil } | ||
func (s *Service) Stop(bool) []error { return nil } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// (c) Cartesi and individual authors (see AUTHORS) | ||
// SPDX-License-Identifier: Apache-2.0 (see LICENSE) | ||
|
||
// A service implementation that simulate a long running Tick | ||
package slow | ||
|
||
import ( | ||
"time" | ||
"github.com/cartesi/rollups-node/pkg/service" | ||
) | ||
|
||
// A Service implementation that takes time to Tick | ||
type Service struct { | ||
service.Service | ||
Time time.Duration | ||
} | ||
|
||
type CreageInfo struct { | ||
service.CreateInfo | ||
Time time.Duration | ||
} | ||
|
||
func Creage(c *CreageInfo, s *Service) error { | ||
s.Time = c.Time | ||
return service.Create(&c.CreateInfo, &s.Service) | ||
} | ||
|
||
func (me *Service) Alive() bool { | ||
return true | ||
} | ||
|
||
func (me *Service) Ready() bool { | ||
return true | ||
} | ||
|
||
func (me *Service) Reload() []error { | ||
return nil | ||
} | ||
|
||
func (me *Service) Tick() []error { | ||
time.Sleep(me.Time) | ||
return nil | ||
} | ||
|
||
func (me *Service) Stop(bool) []error { | ||
return nil | ||
} |