nxcli: github.com/jaracil/nxcli/demos/go/sugar/service Index | Files

package service

import "github.com/jaracil/nxcli/demos/go/sugar/service"

Package service is boilerplate code for making nexus services.


Package Files

semaphore.go service.go

type Method Uses

type Method struct {
    // contains filtered or unexported fields

type Semaphore Uses

type Semaphore struct {
    // contains filtered or unexported fields

func (*Semaphore) Acquire Uses

func (s *Semaphore) Acquire()

func (*Semaphore) Cap Uses

func (s *Semaphore) Cap() int

func (*Semaphore) Free Uses

func (s *Semaphore) Free() int

func (*Semaphore) Release Uses

func (s *Semaphore) Release()

func (*Semaphore) Used Uses

func (s *Semaphore) Used() int

type Service Uses

type Service struct {
    Name             string
    Server           string
    User             string
    Password         string
    Prefix           string
    Pulls            int
    PullTimeout      time.Duration
    MaxThreads       int
    StatsPeriod      time.Duration
    GracefulExitTime time.Duration
    LogLevel         string
    // contains filtered or unexported fields

func (*Service) AddMethod Uses

func (s *Service) AddMethod(name string, f func(*nexus.Task) (interface{}, *nexus.JsonRpcErr))

AddMethod adds (or replaces if already added) a method for the service The function that receives the nexus.Task should return a result or an error

func (*Service) AddMethodSchema Uses

func (s *Service) AddMethodSchema(name string, schema string, f func(*nexus.Task) (interface{}, *nexus.JsonRpcErr))

AddSchemaMethod adds (or replaces if already added) a method for the service with a JSON schema The function that receives the nexus.Task should return a result or an error If the schema validation does not succeed, an ErrInvalidParams error will be sent as a result for the task

func (*Service) GetConn Uses

func (s *Service) GetConn() *nexus.NexusConn

GetConn returns the underlying nexus connection

func (*Service) GetMethods Uses

func (s *Service) GetMethods() []string

GetMethods returns a list of the methods the service has It returns nil if using a handler

func (*Service) GetStats Uses

func (s *Service) GetStats() *Stats

GetStats returns the service stats

func (*Service) GracefulStop Uses

func (s *Service) GracefulStop()

GracefulStop stops pulling tasks, tries to finish working tasks and then cancels nexus connection (with a timeout)

func (*Service) Serve Uses

func (s *Service) Serve() error

Serves connects to nexus, logins, and launches configured TaskPulls.

func (*Service) SetConn Uses

func (s *Service) SetConn(nc *nexus.NexusConn)

SetConn sets the underlying nexus connection. Once SetConn is called, service url, user and password are ignored and the provided connection is used on serve.

func (*Service) SetGracefulExitTime Uses

func (s *Service) SetGracefulExitTime(t time.Duration)

SetGratefulExitTime sets the gracefull waiting time after a call to StopGraceful() is done

func (*Service) SetHandler Uses

func (s *Service) SetHandler(h func(*nexus.Task) (interface{}, *nexus.JsonRpcErr))

SetHandler sets the task handler for all methods, to allow custom parsing of the method When a handler is set, methods added with AddMethod() have no effect Passing a nil will remove the handler and turn back to methods from AddMethod()

func (*Service) SetLogLevel Uses

func (s *Service) SetLogLevel(t string)

SetLogLevel sets the log level

func (*Service) SetMaxThreads Uses

func (s *Service) SetMaxThreads(maxThreads int)

SetMaxThreads modifies the number of maximum concurrent goroutines resolving nexus.Task

func (*Service) SetPass Uses

func (s *Service) SetPass(pass string)

SetPass modifies the service pass

func (*Service) SetPrefix Uses

func (s *Service) SetPrefix(prefix string)

SetPrefix modifies the service prefix

func (*Service) SetPullTimeout Uses

func (s *Service) SetPullTimeout(t time.Duration)

SetPullTimeout modifies the time to wait for a nexus.Task for each nexus.TaskPull call

func (*Service) SetPulls Uses

func (s *Service) SetPulls(pulls int)

SetPulls modifies the number of concurrent nexus.TaskPull calls

func (*Service) SetStatsPeriod Uses

func (s *Service) SetStatsPeriod(t time.Duration)

SetStatsPeriod changes the period for the stats to be printed

func (*Service) SetUrl Uses

func (s *Service) SetUrl(url string)

SetUrl modifies the service url

func (*Service) SetUser Uses

func (s *Service) SetUser(user string)

SetUser modifies the service user

func (*Service) Stop Uses

func (s *Service) Stop()

Stop cancels nexus connection, cancelling all tasks and stops serving

func (*Service) String Uses

func (s *Service) String() string

String returns some service info as a stirng

type Stats Uses

type Stats struct {
    // contains filtered or unexported fields

Package service imports 14 packages (graph) and is imported by 2 packages. Updated 2016-08-06. Refresh now. Tools for package owners.