resources

package
v0.0.0-...-66518bc Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a resource cannot be located.
	ErrNotFound = errors.New("resource not found")
)

Functions

func RegisterResourcesServiceServer

func RegisterResourcesServiceServer(s *grpc.Server, srv ResourcesServiceServer)

Types

type GetRequest

type GetRequest struct {
	Filename             string   `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

* Messages *

func (*GetRequest) Descriptor

func (*GetRequest) Descriptor() ([]byte, []int)

func (*GetRequest) GetFilename

func (m *GetRequest) GetFilename() string

func (*GetRequest) ProtoMessage

func (*GetRequest) ProtoMessage()

func (*GetRequest) Reset

func (m *GetRequest) Reset()

func (*GetRequest) String

func (m *GetRequest) String() string

func (*GetRequest) XXX_DiscardUnknown

func (m *GetRequest) XXX_DiscardUnknown()

func (*GetRequest) XXX_Marshal

func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GetRequest) XXX_Merge

func (dst *GetRequest) XXX_Merge(src proto.Message)

func (*GetRequest) XXX_Size

func (m *GetRequest) XXX_Size() int

func (*GetRequest) XXX_Unmarshal

func (m *GetRequest) XXX_Unmarshal(b []byte) error

type GetResponse

type GetResponse struct {
	Data                 []byte   `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	MimeType             string   `protobuf:"bytes,2,opt,name=mime_type,json=mimeType,proto3" json:"mime_type,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*GetResponse) Descriptor

func (*GetResponse) Descriptor() ([]byte, []int)

func (*GetResponse) GetData

func (m *GetResponse) GetData() []byte

func (*GetResponse) GetMimeType

func (m *GetResponse) GetMimeType() string

func (*GetResponse) ProtoMessage

func (*GetResponse) ProtoMessage()

func (*GetResponse) Reset

func (m *GetResponse) Reset()

func (*GetResponse) String

func (m *GetResponse) String() string

func (*GetResponse) XXX_DiscardUnknown

func (m *GetResponse) XXX_DiscardUnknown()

func (*GetResponse) XXX_Marshal

func (m *GetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GetResponse) XXX_Merge

func (dst *GetResponse) XXX_Merge(src proto.Message)

func (*GetResponse) XXX_Size

func (m *GetResponse) XXX_Size() int

func (*GetResponse) XXX_Unmarshal

func (m *GetResponse) XXX_Unmarshal(b []byte) error

type ResourcesServiceClient

type ResourcesServiceClient interface {
	// Add a new alert. Returns a new resource with information to get it later from the Resource service.
	Add(ctx context.Context, in *cap.Resource, opts ...grpc.CallOption) (*cap.Resource, error)
	// Returns the resource for the given path.
	Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error)
}

ResourcesServiceClient is the client API for ResourcesService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewResourcesServiceClient

func NewResourcesServiceClient(cc *grpc.ClientConn) ResourcesServiceClient

type ResourcesServiceServer

type ResourcesServiceServer interface {
	// Add a new alert. Returns a new resource with information to get it later from the Resource service.
	Add(context.Context, *cap.Resource) (*cap.Resource, error)
	// Returns the resource for the given path.
	Get(context.Context, *GetRequest) (*GetResponse, error)
}

ResourcesServiceServer is the server API for ResourcesService service.

type Server

type Server struct {
	Storage Storage
}

Server is GRPC server for the resource microservice.

func NewServer

func NewServer(storage Storage) (*Server, error)

NewServer creates a new Server.

func (*Server) Add

func (s *Server) Add(ctx context.Context, resource *cap.Resource) (*cap.Resource, error)

Add adds a new resource.

func (*Server) Get

func (s *Server) Get(ctx context.Context, req *GetRequest) (*GetResponse, error)

type Storage

type Storage interface {
	Add(ctx context.Context, filename string, mimetype string, reader io.Reader) error

	Has(ctx context.Context, filename string) (bool, error)

	Get(ctx context.Context, filename string) ([]byte, string, error)
}

Storage defines an interface for resources storage.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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