Skip to content

Instantly share code, notes, and snippets.

@dfranciosi
Created May 5, 2017 13:27
Show Gist options
  • Save dfranciosi/c3ce0cf36986f96bdaec93bfba679cbe to your computer and use it in GitHub Desktop.
Save dfranciosi/c3ce0cf36986f96bdaec93bfba679cbe to your computer and use it in GitHub Desktop.
/* @flow */
import type { Message, SuccessMessage, ErrorMessage, Schedule } from './types';
//eslint-disable-next-line
export const schedulingMessage = (operation: string, targetNodeId: number, payload: Schedule): Message => ({
cmd: `schedule::${operation}`,
args: [targetNodeId, payload],
});
//eslint-disable-next-line
export const applianceMessage = (operation: string, targetNodeId: number, payload: Object): Message => ({
cmd: `appliance::${operation}`,
args: [targetNodeId, payload],
});
//eslint-disable-next-line
export const backupMessage = (operation: string, targetNodeId: number, payload: Object): Message => ({
cmd: `backup::${operation}`,
args: [targetNodeId, payload],
});
export const stateChangeMessage = (whoami: string, state: string): Message => ({
cmd: 'state::change',
args: [whoami, state],
});
export const successMessage = (data: any = []): SuccessMessage => ({
status: 'success',
data,
});
export const errorMessage = (message: string): ErrorMessage => ({
status: 'error',
message,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment