-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: simplify file structure, closes #399
- Loading branch information
Showing
32 changed files
with
797 additions
and
830 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,6 +1,39 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/mesg-foundation/core/database/services" | ||
"github.com/mesg-foundation/core/service" | ||
) | ||
|
||
// DeleteService stops and deletes service serviceID. | ||
func (a *API) DeleteService(serviceID string) error { | ||
return newServiceDeleter(a).Delete(serviceID) | ||
} | ||
|
||
// serviceDeleter provides functionalities to delete a MESG service. | ||
type serviceDeleter struct { | ||
api *API | ||
} | ||
|
||
// newServiceDeleter creates a new serviceDeleter with given. | ||
func newServiceDeleter(api *API) *serviceDeleter { | ||
return &serviceDeleter{ | ||
api: api, | ||
} | ||
} | ||
|
||
// Delete stops and deletes service serviceID. | ||
func (d *serviceDeleter) Delete(serviceID string) error { | ||
s, err := services.Get(serviceID) | ||
if err != nil { | ||
return err | ||
} | ||
s, err = service.FromService(s, service.ContainerOption(d.api.container)) | ||
if err != nil { | ||
return err | ||
} | ||
if err := s.Stop(); err != nil { | ||
return err | ||
} | ||
return services.Delete(serviceID) | ||
} |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.