service

package
v0.0.0-...-2dead57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusPending is the status of a pending request
	StatusPending = "pending"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovalReqType

type ApprovalReqType struct {
	ID             string     `json:"id"`
	From           string     `json:"from"`
	Approvers      []string   `json:"approvers"`
	To             []UserType `json:"to"`
	FileID         string     `json:"fileId"`
	FileName       string     `json:"fileName"`
	Info           string     `json:"info"`
	Classification string     `json:"classification"`
}

ApprovalReqType is the struct sent as json to the approval service

type Controller

type Controller interface {
	CreatePermit(ctx context.Context, reqID string, fileID string, userID string, status string) (Permit, error)
	GetPermitsByFileID(ctx context.Context, fileID string) ([]*pb.UserStatus, error)
	HasPermit(ctx context.Context, fileID string, userID string) (bool, error)
	UpdatePermitStatus(ctx context.Context, reqID string, status string) (bool, error)
	HealthCheck(ctx context.Context) (bool, error)
}

Controller is an interface for the business logic of the permit.Service which uses a Store.

type Permit

type Permit interface {
	GetID() string
	SetID(id string) error

	GetReqID() string
	SetReqID(reqID string) error

	GetFileID() string
	SetFileID(fileID string) error

	GetUserID() string
	SetUserID(userID string) error

	GetStatus() string
	SetStatus(status string) error

	MarshalProto(permit *pb.PermitObject) error
}

Permit is an interface of a permit object.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the structure used for handling

func NewService

func NewService(controller Controller, logger *logrus.Logger, spikeConn *grpc.ClientConn, grantType string, audience string, approvalURL string) Service

NewService creates a Service and returns it.

func (Service) CreatePermit

func (s Service) CreatePermit(ctx context.Context, req *pb.CreatePermitRequest) (*pb.CreatePermitResponse, error)

CreatePermit is the request handler for creating a permit of a file to user.

func (Service) GetPermitByFileID

GetPermitByFileID is the request handler for getting a permit (user, status) by file id.

func (Service) HasPermit

func (s Service) HasPermit(ctx context.Context, req *pb.HasPermitRequest) (*pb.HasPermitResponse, error)

HasPermit is the request handler for checking if a permit exists for fileID and userID.

func (*Service) HealthCheck

func (s *Service) HealthCheck(mongoClientPingTimeout time.Duration) bool

HealthCheck checks the health of the service, and returns a boolean accordingly.

func (Service) UpdatePermitStatus

UpdatePermitStatus is the request handler for updating the status of a given permit.

type Store

type Store interface {
	Create(ctx context.Context, permit Permit) (Permit, error)
	Get(ctx context.Context, filter interface{}) (Permit, error)
	GetAll(ctx context.Context, filter interface{}) ([]Permit, error)
	Delete(ctx context.Context, filter interface{}) (Permit, error)
	HealthCheck(ctx context.Context) (bool, error)
}

Store is an interface for handling the storing of permissions.

type UserType

type UserType struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

UserType is the struct that contains id and fullname of a user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL