offers

package
v0.0.0-...-21ef3ff Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package marketing provides an example service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewJSONRPCHandler

func NewJSONRPCHandler(s *rpc.Server) http.Handler

NewJSONRPCHandler makes a JSON-RPC handler for s.

Types

type Client

type Client struct {
	// Client is the wrapped RPC client.
	*rpc.Client
	// Configuration is the configuration.
	Configuration Configuration
	// Context is the call context.
	Context Context
	// Name is the receiver name.
	Name string
}

Client is the RPC client.

func MustNewClient

func MustNewClient(c Configuration, address string) Client

MustNewClient calls NewClient and panics if there is an error.

func NewClient

func NewClient(c Configuration, address string) (Client, error)

NewClient makes a Client that uses h and dials address.

func (Client) Delete

func (c Client) Delete(m offer.Offer) (offer.Offer, error)

Delete deletes m.

func (Client) ForContext

func (c Client) ForContext(co Context) Interface

ForContext uses c.

func (Client) Get

func (c Client) Get(id string) (offer.Offer, error)

Get gets the Offer for id.

func (Client) New

func (c Client) New(m offer.Offer) (offer.Offer, error)

New creates m.

func (Client) Set

func (c Client) Set(m offer.Offer) (offer.Offer, error)

Set updates m.

type Configuration

type Configuration struct {
	// Name is the Offers name.
	Name string
	// OfferRepository is a model repository.
	OfferRepository offer.Repository
}

Configuration is the Offers configuration.

func (Configuration) OnCall

func (conf Configuration) OnCall(method string, cont Context, argument interface{})

OnCall is called before calling a service method. OnCall is a special method.

func (Configuration) OnPanic

func (conf Configuration) OnPanic(method string, cont Context, value interface{})

OnPanic is called when recovering from a panic in a service method. OnPanic is a special method.

func (Configuration) OnReturn

func (conf Configuration) OnReturn(method string, cont Context, result interface{}, err error)

OnReturn is called after a service method returns. OnReturn is a special method.

type Context

type Context struct {
	// ID identifies the call.
	ID string
}

Context is the Offers context.

type Interface

type Interface interface {
	// Delete deletes m.
	Delete(m offer.Offer) (offer.Offer, error)
	// ForContext uses c.
	ForContext(c Context) Interface
	// Get gets the Offer for id.
	Get(id string) (offer.Offer, error)
	// New creates m.
	New(m offer.Offer) (offer.Offer, error)
	// Set updates m.
	Set(m offer.Offer) (offer.Offer, error)
}

Interface is the service interface.

type Offers

type Offers struct {
	// Configuration is the configuration.
	Configuration Configuration
	// Context is the call context.
	Context Context
}

Offers is an example service.

func (Offers) Delete

func (os Offers) Delete(o offer.Offer) (offer.Offer, error)

Delete deletes o.

func (Offers) ForContext

func (os Offers) ForContext(c Context) Interface

ForContext uses c.

func (Offers) Get

func (os Offers) Get(id string) (offer.Offer, error)

Get gets the Offer for id.

func (Offers) New

func (os Offers) New(o offer.Offer) (offer.Offer, error)

New creates o.

func (Offers) Set

func (os Offers) Set(o offer.Offer) (offer.Offer, error)

Set updates o.

type Receiver

type Receiver struct {
	// Configuration is the configuration.
	Configuration Configuration
	// Interface is the service.
	Interface Interface
}

Receiver is an RPC receiver.

func (Receiver) Delete

func (r Receiver) Delete(argument struct {
	Arguments struct {
		M offer.Offer // m
	}
	Context Context // Call context
}, result *struct {
	Offer offer.Offer // Only one non-error result
}) error

Delete deletes M.

func (Receiver) Get

func (r Receiver) Get(argument struct {
	Context   Context
	Arguments struct {
		Id string
	}
}, result *struct {
	Offer offer.Offer
}) error

Get gets the Offer for id.

func (Receiver) New

func (r Receiver) New(argument struct {
	Context   Context
	Arguments struct {
		M offer.Offer
	}
}, result *struct {
	Offer offer.Offer
}) error

New creates M.

func (Receiver) Set

func (r Receiver) Set(argument struct {
	Context   Context
	Arguments struct {
		M offer.Offer
	}
}, result *struct {
	Offer offer.Offer
}) error

Set updates M.

type Server

type Server struct {
	// Server is the wrapped RPC server.
	*rpc.Server
	// Listener is the listener.
	Listener net.Listener
}

Server is the RPC server.

func MustNewServer

func MustNewServer(c Configuration, i Interface, address string) Server

MustNewServer calls NewServer and panics if there is an error.

func NewServer

func NewServer(c Configuration, i Interface, address string) (Server, error)

NewServer makes a Server that uses h and s and listens to address.

func (Server) Start

func (s Server) Start() error

Start starts the server.

func (Server) Stop

func (s Server) Stop() error

Stop stops the server.

type Suite

type Suite struct {
	suite.Suite
	Interface func() Interface
}

Suite is the test suite.

func (*Suite) TestDelete

func (s *Suite) TestDelete()

func (*Suite) TestGet

func (s *Suite) TestGet()

func (*Suite) TestNew

func (s *Suite) TestNew()

func (*Suite) TestSet

func (s *Suite) TestSet()

Jump to

Keyboard shortcuts

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